|
| 1 | +--- |
| 2 | +title: Large data |
| 3 | +description: Pass large outputs, loop results, and files between blocks within Sim's size limits. |
| 4 | +--- |
| 5 | + |
| 6 | +Sim stores block outputs larger than 8 MiB with the run and loads them only when a block reads them. Read the fields a block needs rather than a whole large output, and keep loop results small. |
| 7 | + |
| 8 | +## Size limits |
| 9 | + |
| 10 | +| Limit | Size | |
| 11 | +| --- | --- | |
| 12 | +| One stored value | 64 MiB | |
| 13 | +| One stored value loaded by a block at once | 16 MiB | |
| 14 | +| One file read by Function code | 64 MiB | |
| 15 | +| One `sim.files` read or chunk | 10 MiB | |
| 16 | + |
| 17 | +Sim stores large fields and array chunks as separate values, so a whole block output can exceed 64 MiB when no single piece does. A block that exceeds a limit fails with an `Execution memory limit exceeded` error that names the size and the limit. |
| 18 | + |
| 19 | +## Reference fields, not whole outputs |
| 20 | + |
| 21 | +Use `<api.data.items[0].id>` instead of `<api.data>`. Sim stores large arrays in chunks, so an indexed path loads only the chunk it reads. A field inside a large object still loads that whole object, so the object must fit the 16 MiB limit; when it does not, have the block that produces it return less. |
| 22 | + |
| 23 | +Only JavaScript Function code without imports can receive a whole large value; Sim loads it when the code runs, up to 16 MiB. Agent, API, and other block inputs, Python and Shell code, and JavaScript with imports must reference a smaller field. A reference to an object that contains a large value fails with `contains nested large values`; reference the nested field instead. |
| 24 | + |
| 25 | +An Agent prompt is also bound by its model's context window. Pass a summary or the fields the model needs, not a full dataset. |
| 26 | + |
| 27 | +## Keep loop results small |
| 28 | + |
| 29 | +A Loop or Parallel `results` value holds every block output from every iteration. It grows with both the iteration count and the number of blocks inside, so a loop that reads a table on each pass stores a copy of those rows for every iteration. |
| 30 | + |
| 31 | +- Read data that does not change between iterations once, before the loop. |
| 32 | +- Read one entry with an indexed path, such as `<processreviews.results[0][0].content>`. Indexed paths load only that entry. |
| 33 | +- To collect a summary from a Loop, have its last block return a compact record and append it to a [workflow variable](/workflows/variables) or a Table row. Read that after the loop instead of `results`. In a Parallel, write each branch's record to a Table rather than a shared variable. |
| 34 | + |
| 35 | +## Large files |
| 36 | + |
| 37 | +A file output is metadata: `<file.name>` and `<file.url>` do not load its contents. In JavaScript Function code without imports, read contents with the [`sim.files` helpers](/workflows/blocks/function#large-inputs). For files over 10 MiB, read in chunks with `readTextChunk` or `readBase64Chunk`. |
| 38 | + |
| 39 | +## Keep reusable datasets in a Table |
| 40 | + |
| 41 | +For data that several blocks or runs need, write it to a [Table](/tables) and query the rows each step needs. Pass row IDs or filters between blocks instead of the rows themselves. |
| 42 | + |
| 43 | +## Related docs |
| 44 | + |
| 45 | +- [How blocks pass data](/workflows/data-flow) |
| 46 | +- [Connection syntax](/workflows/connections) |
| 47 | +- [Loop](/workflows/blocks/loop) |
| 48 | +- [Parallel](/workflows/blocks/parallel) |
| 49 | +- [Function](/workflows/blocks/function) |
| 50 | +- [Tables in workflows](/tables/using-in-workflows) |
0 commit comments