Skip to main content

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...

Workflow Authoring

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_uuid or _workflow_id) are managed exclusively by the platform. Untrusted keys like _tenant_id or _account_id in 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:

  1. Scoped Data Wires (Default for compiled diagrams): When graph.wires is present, the engine collects every wire where to_node == B:

    Code
    {
      "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 into B's scoped input dictionary under to_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.

  2. 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:

Code
{
  "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 FromNode is an entry trigger (IsEntry = true), the compiler automatically maps from_node to "__initial__" in graph.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.):

  1. If an explicit wire already feeds (targetNode, inputKey), the explicit wire wins.
  2. Otherwise, the serializer walks backwards through reachable upstream nodes looking for the nearest node whose OutputKey matches inputKey and emits { from_node: sourceNode.Id, from_key: inputKey, to_node: targetNode.Id, to_key: inputKey }.
  3. If no upstream node declares that OutputKey, the serializer wires it from "__initial__".

Important: Because automatic inference matches a node's primary OutputKey, use explicit DataWires whenever 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:

Code
{
  "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_keys to send PDFs, images, audio, or text files multimodally.
    • Python Script: FileRef inputs 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 FileRef files or row arrays directly into Parquet, CSV, or JSONL datasets.

5. Parallel Fan-Out & Sub-Workflow Data Isolation

Parallel Fan-Out (logic_parallel)

  1. Extracts an array from parent state using JMESPath path (for example, dataset_files or orders.items).
  2. 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 (default item).
  3. Collects every child's completed final state dictionary in order into a single JSON array written to parent state under output_key (default results).

Sub-Workflows (sub_workflow)

  1. Declares explicit Inputs (0..M-1) and Outputs (M..M+N-1) port keys.
  2. Passes matching scoped keys into the child workflow's initial state and merges the child's completed state back into the parent when finished.
  3. 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.