Expression and I/O Rules — Accessing Diagram Fields from Every Node
LLM4B provides four complementary ways for a node to read fields from your workflow diagram's state, depending on what the node does: **template interpolatio...
Expression and I/O Rules — Accessing Diagram Fields from Every Node
LLM4B provides four complementary ways for a node to read fields from your workflow diagram's state, depending on what the node does: template interpolation, JMESPath expressions, direct state-key selectors, and Python / Sub-Workflow context mappings. This guide documents the exact syntax, runtime boundaries, and a complete node-by-node I/O matrix.
1. Template Interpolation ({{key}} and {key})
String templates are rendered using a deterministic placeholder matcher that recognizes both double-brace {{key}} (recommended) and single-brace {key} syntax:
- Allowed key characters:
[A-Za-z0-9_]+(letters, digits, and underscores). - Missing keys: If a referenced key is absent from the node's scoped state, it resolves cleanly to an empty string
""rather than throwing. - JSON safety: Prefer double braces
{{key}}inside JSON payloads (such as HTTP Request bodies or Webhook Callback templates) so literal JSON braces{ ... }remain intact while{{key}}is substituted. - Top-level key scope: Template placeholders read top-level keys from the node's scoped state (
state[key]). They do not evaluate nested dot-paths like{{order.customer.email}}. To interpolate a nested property inside a template, extract it first with a Python Script or Regex Operation node, or map the specific field cleanly with an explicit Data Wire.
Where template interpolation is supported:
- LLM Inference —
prompt_template(whenprompt_source: "template") - AI Agent —
prompt_template(whenprompt_source: "template") - Prompt Template — versioned prompt text
- HTTP Request —
url,query_params,headers,body_template,body_form_params,auth_username, andoutput_filename - Webhook Callback —
urlandpayload_template(whenpayload_source: "custom_template") - Dataset Read —
partition_filter - Dataset Write —
partition_pathandfilename_template - Workflow Output & Finish —
payload_template(whenpayload_source: "custom_template")
2. JMESPath Expressions (path)
Branching and fan-out nodes evaluate full JMESPath queries against the node's resolved state dictionary—giving you deep access into nested JSON objects, arrays, and computed projections:
| Pattern | Example path |
What It Reads |
|---|---|---|
| Top-level key | score |
state["score"] |
| Nested object field | classification.confidence |
state["classification"]["confidence"] |
| Array element | orders[0].total |
First order's total field |
| Array projection | orders[*].sku |
List of all SKUs across orders |
| Filtered list | items[?price > \100`]| Items withpriceabove100` |
|
| Built-in function | length(dataset_files) |
Count of elements in dataset_files |
Where JMESPath is supported:
- Condition — evaluates
path, then compares againstvalueusing<,<=,>,>=,==, or!=to picktrueorfalse. - Router — evaluates
path, converts the result to string, and routes to the matching branch incasesor falls back todefault. - Parallel Fan-out — evaluates
pathto extract the list/array to iterate over concurrently.
3. Direct State-Key Selectors & Payload Modes
Several nodes read a complete structured value (string, JSON object, list, or FileRef) directly by state key name without stringification:
input_key: Used by LLM Inference (prompt_source: "state_key"), AI Agent (prompt_source: "state_key"), Python Script, Regex Operation, and Dataset Write.file_input_keys: List of state keys holdingFileRefhandles attached multimodally to LLM Inference.payload_source/payload_key/payload_template: Shared across Webhook Callback, Workflow Output, and Finish:entire_state— emits all non-internal (non-_) keys from the node's state.specific_key(orstate_key) — emits the exact value stored atpayload_key.custom_template— renderspayload_templatevia{{key}}interpolation (and auto-parses as JSON whencontent_typeisapplication/json).
4. Python Sandbox & Sub-Workflow Contexts
- Python Script: Your script receives an
inputsdictionary containinginputs["input"](resolved frominput_key) plus every other non-internal scoped state key (e.g.,inputs.get("customer_tier")). AnyFileRefvalues are staged on local sandbox disk automatically. Assign return fields intooutputs[...]and the node writesoutputsto state underoutput_key. - Sub-Workflow: Maps each declared key in
Inputsinto the child workflow's initial state and merges child outputs back into parent state.
5. Explicit DataWires Syntax
Prefer explicit DataWires inside each WorkflowWireSpec entry in Wires (or AddWires in a WorkflowGraphPatch) whenever renaming keys, disambiguating branches, or consuming secondary output keys:
{
"FromNode": "fetch_1",
"FromPort": 1,
"ToNode": "llm_1",
"ToPort": 0,
"DataWires": [
{ "FromKey": "http_response", "ToKey": "rendered_prompt" }
]
}
Each WorkflowDataWireSpec object uses { "FromKey": "<upstream_output_key>", "ToKey": "<downstream_input_key>" } (never put from_node/to_node inside DataWires—those belong to WorkflowWireSpec.FromNode and WorkflowWireSpec.ToNode).
- Avoid duplicate
output_keynames across active branches unless intentionally overwriting a shared state key. - Internal
_-prefixed keys are always stripped fromentire_statepayloads and user script inputs.
6. Node-by-Node Field Access & Output Key Matrix
| Node | How It Reads Diagram Fields | State Keys Written (Primary & Secondary) |
|---|---|---|
| Workflow Input | Run payload / test_payload JSON |
All top-level payload keys (__initial__) |
| HTTP Webhook | Inbound POST JSON body | All top-level body keys (__initial__) |
| Cron Schedule | Recurring cron schedule (crons, timezone, overlap, pause_on_failure, catchup_window_minutes) |
Passes initial state through (__initial__) |
| Periodic Interval | Fixed-minute interval schedule (interval_minutes, jitter_seconds, overlap, pause_on_failure, catchup_window_minutes) |
Passes initial state through (__initial__) |
| Signal Trigger | External signal JSON payload | All signal payload keys merged into state |
| Condition | JMESPath path + op + value |
None (passthrough; activates true or false branch) |
| Router | JMESPath path matched against cases |
None (passthrough; activates matching case or default) |
| Parallel Fan-out | JMESPath path (array) |
{output_key} (ordered array of child final states) |
| Sub-Workflow | Declared Inputs port keys |
Declared child Outputs merged into parent state |
| Wait / Timer | None (passthrough) | None (preserves upstream state) |
| Regex Operation | input_key (string) |
{output_key} (string, bool, or list) |
| Prompt Template | {{key}} / {key} in prompt asset |
{output_key} (default rendered_prompt) |
| LLM Inference | input_key or prompt_template ({{key}}) + file_input_keys (FileRef) |
{output_key}, {output_key}_metadata |
| AI Agent | input_key or prompt_template ({{key}}) |
{output_key}, {output_key}_raw, {output_key}_turns, {output_key}_tool_calls |
| HTTP Request | {{key}} in url, query_params, headers, body_template, output_filename |
{output_key}, {output_key}_status, {output_key}_headers |
| Python Script | inputs["input"] (input_key) + all scoped non-_ keys |
{output_key} (default python_result) |
| Approval Gate | Scoped review context + reviewer decision | {output_key} (default approval_result) |
| Dataset Read | {{key}} in partition_filter |
{output_key}, {output_key}_files, {output_key}_count |
| Dataset Write | input_key (rows or FileRef) + {{key}} in partition_path, filename_template |
{output_key}, {output_key}_rows_written, {output_key}_schema, {output_key}_stats |
| Webhook Callback | {{key}} in url + payload_source (entire_state, payload_key, payload_template) |
{response_state_key}, {response_state_key}_status |
| Workflow Output | payload_source (entire_state, payload_key, payload_template) |
_workflow_output |
| Finish | Static message or source_from_input payload |
_finish_message, _workflow_output |
7. Validation Modes
AuthoringDraft: Allows incomplete draft fields (such as an unconfigured webhook secret or missing BYOK credential) asWarningdiagnostics while blocking structural, unknown-type, cycle, or quota errors.StrictRunReady: Enforces full node readiness (NODE_NOT_READY,SECRET_REFERENCE_NOT_FOUND,SKILL_NOT_FOUND,DATASET_GOVERNANCE_ERROR) asErrordiagnostics before execution.