Skip to content

Commit 577073c

Browse files
committed
docs(workflows): add large data page with size limits and loop result guidance
1 parent 4c0ac32 commit 577073c

6 files changed

Lines changed: 56 additions & 4 deletions

File tree

‎apps/docs/content/docs/workflows/blocks/function.mdx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,9 +427,9 @@ const chunk = await sim.files.readTextChunk(file, { offset: 0, length: 1024 * 10
427427
const bytes = await sim.files.readBase64Chunk(file, { offset: 0, length: 1024 * 1024 });
428428
```
429429

430-
`sim.files.readText`, `readBase64`, and the `…Chunk` variants stream from execution storage under memory caps. `sim.values.read(ref)` and `sim.values.readArray(ref)` read large value and array references. Chunk `offset` and `length` are byte-based, so for exact Unicode parsing prefer smaller structured references. For large generated data in a remote Function block, write files under `/tmp/sim/outputs` and pass them to a compatible File or Table action. The separate Function tool exposes `outputPath`, `outputSandboxPath`, and `outputTable` for explicit persistence; those are not builder fields.
430+
`sim.files` reads a file of up to 64 MiB and returns at most 10 MiB per call, so read larger files in chunks. `sim.values.read(ref)` and `sim.values.readArray(ref)` read large value and array references. Chunk `offset` and `length` are byte-based, so for exact Unicode parsing prefer smaller structured references. For large generated data in a remote Function block, write files under `/tmp/sim/outputs` and pass them to a compatible File or Table action. The separate Function tool exposes `outputPath`, `outputSandboxPath`, and `outputTable` for explicit persistence; those are not builder fields.
431431

432-
The lazy `sim.files` and `sim.values` helpers are available only in JavaScript functions without imports. JavaScript with imports, Python, and Shell do not support them yet.
432+
The lazy `sim.files` and `sim.values` helpers are available only in JavaScript functions without imports. JavaScript with imports, Python, and Shell do not support them yet. See [Large data](/workflows/large-data) for every size limit.
433433

434434
## Errors and timeout
435435

‎apps/docs/content/docs/workflows/blocks/loop.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Results group the inner block outputs by iteration. For a single Agent in each i
5353
]
5454
```
5555

56-
Use `<processreviews.results[0][0].content>` for the first iteration's first block result. Additional blocks can contribute additional outputs per iteration.
56+
Use `<processreviews.results[0][0].content>` for the first iteration's first block result. Additional blocks can contribute additional outputs per iteration, so results grow with every block inside the loop; see [keep loop results small](/workflows/large-data#keep-loop-results-small).
5757

5858
## Behavior and limits
5959

‎apps/docs/content/docs/workflows/blocks/parallel.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Arrays yield their values as `currentItem`. Objects yield `[key, value]` pairs,
3838

3939
After completion, use the container's normalized name: `<processtasks.results>`. Generic `<parallel.*>` references select an enclosing parallel context, not a completed container outside it.
4040

41-
Results retain input/instance order, even when branches finish out of order. Each entry contains that branch's block outputs. For a single API per branch, read a field with `<processtasks.results[10][0].data.id>`. Indexed paths hydrate oversized entries only when needed.
41+
Results retain input/instance order, even when branches finish out of order. Each entry contains that branch's block outputs. For a single API per branch, read a field with `<processtasks.results[10][0].data.id>`. Indexed paths hydrate oversized entries only when needed. See [keep loop results small](/workflows/large-data#keep-loop-results-small).
4242

4343
## State and failures
4444

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 block output | 64 MiB |
13+
| One value loaded into Function code at once | 16 MiB |
14+
| One file read by Function code | 64 MiB |
15+
| One `sim.files` read or chunk | 10 MiB |
16+
17+
These are hard limits. A block that exceeds one 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 loads a large output only as far as the path requires, so a small field inside a large output stays cheap to read.
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)

‎apps/docs/content/docs/workflows/meta.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"how-it-runs",
66
"connections",
77
"variables",
8+
"large-data",
89
"code",
910
"workspace-code",
1011
"deployment",

‎apps/sim/lib/mothership/generated/docs-manifest.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,7 @@ export const DOCS_MANIFEST: readonly string[] = [
509509
'workflows/deployment/chat.mdx',
510510
'workflows/deployment/mcp.mdx',
511511
'workflows/how-it-runs.mdx',
512+
'workflows/large-data.mdx',
512513
'workflows/triggers/rss.mdx',
513514
'workflows/triggers/schedule.mdx',
514515
'workflows/triggers/sim.mdx',

0 commit comments

Comments
 (0)