How Data Flows Between Nodes
LLM4B passes structured JSON data and large file references cleanly from entry triggers through intermediate processing nodes to final outputs. This guide ex...
How Data Flows Between Nodes
LLM4B passes structured JSON data and large file references cleanly from entry triggers through intermediate processing nodes to final outputs. This guide explains the exact runtime state model, how Data Wires isolate and rename keys, how automatic wire inference works, and how special containers like FileRef, Parallel Fan-out, and Sub-Workflows carry data.
1. Initial Workflow Input (__initial__)
Every execution begins by seeding workflow state from the run's initial input object and storing a snapshot under the special source ID __initial__:
| Entry Trigger | Where Initial Keys Come From |
|---|---|
| Workflow Input | JSON passed in the Run dialog, API call, or parent Sub-Workflow (or test_payload when running directly in the Designer). |
| HTTP Webhook | Top-level properties of the inbound HTTP POST JSON body (or test_payload during Designer test runs). |
| Signal Trigger | Initial run input plus every key merged from the external signal JSON payload when the signal arrives. |
| Scheduled / Interval Triggers | Optional initial payload configured on the workflow; defaults to an empty object {} (or {"prompt": "..."} when initial_prompt is set). |
Security: Internal runtime metadata keys prefixed with
_(such as_project_uuidor_workflow_id) are managed exclusively by the platform. Untrusted keys like_tenant_idor_account_idin external payloads are stripped automatically.
2. Shared State Snapshots vs. Scoped Data Wires
As each node finishes, the Workflow Engine merges the node's returned state_update dictionary into the workflow's cumulative state and records a snapshot at node_outputs[node_id].
Before executing any downstream node B, the engine constructs B's input dictionary in one of two ways:
Scoped Data Wires (Default for compiled diagrams): When
graph.wiresis present, the engine collects every wire whereto_node == B:{ "from_node": "http_1", "from_key": "http_response", "to_node": "llm_1", "to_key": "article_body" }For each matching wire, the engine reads
node_outputs[from_node][from_key]and places it intoB's scoped input dictionary underto_key. This provides strict key isolation and lets you rename an upstream output key to match what the downstream node expects—without mutating other branches.Full Shared State Fallback: If a graph omits
wires(wires: null), the node receives a copy of the entire cumulative workflow state dictionary.
3. Explicit Data Wires vs. Automatic Wire Inference
You can control data wiring in two ways:
Explicit DataWires (Recommended for renaming or disambiguation)
In a WorkflowAuthoringSpec or WorkflowGraphPatch, attach DataWires directly to any edge in Wires / AddWires:
{
"FromNode": "fetch_1",
"FromPort": 1,
"ToNode": "llm_1",
"ToPort": 0,
"DataWires": [
{ "FromKey": "http_response", "ToKey": "source_document" },
{ "FromKey": "http_response_status", "ToKey": "status_code" }
]
}
- Each entry uses
{ "FromKey": "<upstream_key>", "ToKey": "<downstream_key>" }. - If
FromNodeis an entry trigger (IsEntry = true), the compiler automatically mapsfrom_nodeto"__initial__"ingraph.wires.
Automatic Wire Inference (Visual Designer & Default Wiring)
Whenever a diagram is saved or compiled, the serializer inspects every reachable node's declared input keys (template placeholders like {{customer_id}}, input_key, JMESPath root keys, file_input_keys, payload_key, etc.):
- If an explicit wire already feeds
(targetNode, inputKey), the explicit wire wins. - Otherwise, the serializer walks backwards through reachable upstream nodes looking for the nearest node whose
OutputKeymatchesinputKeyand emits{ from_node: sourceNode.Id, from_key: inputKey, to_node: targetNode.Id, to_key: inputKey }. - If no upstream node declares that
OutputKey, the serializer wires it from"__initial__".
Important: Because automatic inference matches a node's primary
OutputKey, use explicitDataWireswhenever you want to wire a secondary output key (such as{output_key}_status,{output_key}_headers,{output_key}_files,{output_key}_count, or{output_key}_turns) or when two upstream branches produce the same key name.
4. Passing Large & Binary Data with FileRef
Workflow history is optimized for structured metadata, not multi-megabyte files. Nodes that handle large files or binary artifacts pass lightweight FileRef handles instead of raw bytes:
{
"type": "file_ref",
"uri": "storage://tenant/.../report.pdf",
"filename": "report.pdf",
"mime_type": "application/pdf",
"size_bytes": 482910
}
- Producers: Dataset Read, HTTP Request (
response_mode: "fileref"), Python Script (staged artifacts), and Dataset Write. - Consumers:
- LLM Inference: list the state key(s) in
file_input_keysto send PDFs, images, audio, or text files multimodally. - Python Script:
FileRefinputs are staged automatically onto local sandbox disk so scripts can open them directly with pandas, PyArrow, or standard file I/O. - Dataset Write: persists incoming
FileReffiles or row arrays directly into Parquet, CSV, or JSONL datasets.
- LLM Inference: list the state key(s) in
5. Parallel Fan-Out & Sub-Workflow Data Isolation
Parallel Fan-Out (logic_parallel)
- Extracts an array from parent state using JMESPath
path(for example,dataset_filesororders.items). - Launches one concurrent child execution per element. Each child receives a copy of the parent's resolved state plus the current element bound under
loop_var_name(defaultitem). - Collects every child's completed final state dictionary in order into a single JSON array written to parent state under
output_key(defaultresults).
Sub-Workflows (sub_workflow)
- Declares explicit
Inputs(0..M-1) andOutputs(M..M+N-1) port keys. - Passes matching scoped keys into the child workflow's initial state and merges the child's completed state back into the parent when finished.
- Guards automatically against infinite recursion using depth and visited-workflow checks.
Next, read Expression and I/O Rules for the exact syntax to access diagram fields from every node type.