How Diagram Definitions Work
Every LLM4B workflow is stored as a single structured JSON **diagram definition**. Understanding its two layers—the **visual layout** used by the Workflow De...
How Diagram Definitions Work
Every LLM4B workflow is stored as a single structured JSON diagram definition. Understanding its two layers—the visual layout used by the Workflow Designer canvas and the compiled execution graph used by the Workflow Engine—makes it easy to author, inspect, debug, and automate diagrams reliably.
Two Layers of a Workflow Definition
When you save a workflow from the Designer (or compile a semantic WorkflowAuthoringSpec through Builder Copilot), LLM4B persists one JSON document with four top-level fields:
{
"version": 1,
"initial_prompt": "Summarize today's urgent tickets",
"layout": {
"nodes": [ ... ],
"annotations": [ ... ],
"links": [ ... ],
"zoom": 1.0,
"panX": 0,
"panY": 0
},
"graph": {
"entry": "in_1",
"nodes": { ... },
"wires": [ ... ]
},
"wires": [ ... ]
}
| Section | Purpose |
|---|---|
version |
Schema version (currently 1). |
initial_prompt |
Optional default prompt string used when no JSON test_payload overrides initial input. |
layout |
Visual canvas state: each node's (x, y) coordinates, flowDirection (LTR, RTL, TTB, BTT), optional caption and captionOffsetX/Y, sticky-note annotations, port-to-port visual links, and viewport zoom/pan. |
graph |
Executable directed acyclic graph (DAG) consumed by the Workflow Engine at runtime. Contains entry (entry node ID), nodes (map of node ID → runtime node spec), wires (explicit and inferred data-routing table), and optional resilience (retry_max_attempts, retry_initial_interval_seconds, retry_backoff_coefficient, activity_timeout_seconds, max_workflow_run_duration_seconds, manual_overlap_policy). |
Tip: When authoring workflows programmatically or with Builder Copilot, write a high-level
WorkflowAuthoringSpec(orWorkflowGraphPatch) instead of raw canvas coordinates—the deterministic graph compiler generates bothlayoutandgraphautomatically.
Cascading Resilience & Retries (graph.resilience)
Workflow-level retry and step-timeout defaults live under graph.resilience and cascade automatically to every activity-backed step (action_http, output_webhook, llm, maf_agent, llm_prompt, action_python, dataset_read, dataset_write):
"resilience": {
"retry_max_attempts": 3,
"retry_initial_interval_seconds": 1.0,
"retry_backoff_coefficient": 2.0,
"activity_timeout_seconds": 1800,
"max_workflow_run_duration_seconds": 3600,
"manual_overlap_policy": "AllowAll"
}
- 3-Tier Resolution Order: For each activity step, the Workflow Engine resolves retries and step timeouts in strict priority order:
- Per-node override inside
node.config(retry_max_attempts,retry_initial_interval_seconds,retry_backoff_coefficient,activity_timeout_seconds— omitted when inheriting). - Side-effect safe default or workflow default: Non-idempotent outbound actions (
output_webhookandaction_httpusingPOST,PUT,PATCH, orDELETE) default to1attempt (no auto-retry) unless explicitly overridden on that node; read/compute steps (includingGETHTTP requests) inheritgraph.resilience. - Platform fallback:
3attempts,1.0sinitial delay,2.0xbackoff multiplier, and1800sstep timeout.
- Per-node override inside
- Confirmed Platform Bounds:
retry_max_attempts(1–10),retry_initial_interval_seconds(0.5–300.0),retry_backoff_coefficient(1.0–5.0),activity_timeout_seconds(10–3600), andmax_workflow_run_duration_seconds(10–86400, optional). - Non-Retryable Errors: Configuration, permission, blocked-network, and validation (
4xx) errors fail immediately without retrying; automatic retries apply only to transient network, rate-limit (429), and server (5xx) failures. - Deterministic & Wait Steps: Pure in-workflow nodes (
logic_condition,logic_switch,logic_regex,logic_parallel,logic_timer,action_approval,sub_workflow, entry triggers, and terminal exits) do not take retry overrides.
Anatomy of an Executable Graph (graph)
Inside graph.nodes, every reachable node is keyed by its unique id and serialized into one of three runtime shapes:
- Sequential / Activity Nodes (
nextedge):"http_1": { "type": "activity", "activity": "http_request_activity", "config": { "method": "GET", "url": "https://api.example.com/v1/orders/{{order_id}}", "output_key": "order_data" }, "next": "cond_1" } - Branching Nodes (
logic_condition,logic_switch) (expression+branchesmap):"cond_1": { "type": "switch", "expression": { "path": "order_data.total", "op": ">=", "value": 500 }, "branches": { "true": "approve_1", "false": "out_ok" } }logic_conditionincludes"op"and"value"insideexpressionand routes strictly to"true"or"false".logic_switchomits"op"and matchesstr(jmespath(path, state))against named keys inbranches, falling back to"default".
- Entry & Terminal Nodes:
- Entry triggers (
trigger_input,trigger_webhook,trigger_signal,trigger_schedule,trigger_interval) sit atgraph.entryand have zero input ports. - Terminal exits (
output_return→"type": "terminal",output_finish→"type": "terminal_finish") have zero output ports. - Non-terminal output nodes such as Webhook Callback expose an optional output port (
1) and continue tonextwhen wired.
- Entry triggers (
How the Workflow Engine Executes a Diagram
The Workflow Engine traverses graph using a topological readiness queue (adapted Kahn's algorithm):
- Predecessors & In-Degree: Before starting, the engine builds predecessor/successor maps from every
nextandbranchesedge and counts each node'sin_degree(number of upstream predecessors). - Entry Seed: The node referenced by
graph.entryis placed into the ready queue with initial input stored under__initial__. - Concurrent Dispatch: Every node whose
in_degreereaches0runs asynchronously. Parallel sibling branches execute concurrently, and a fan-in (join) node automatically waits until all of its predecessors finish or are bypassed. - Conditional Branching & Dead-Path Elimination:
- When a
switch/logic_conditionnode evaluates, only its chosen branch's successor is activated. - All unchosen branches undergo recursive bypass propagation: downstream nodes whose predecessors are all bypassed are automatically marked
bypassedand skipped without executing. - If a join node downstream has one active predecessor and one bypassed predecessor, the bypassed edge still decrements
in_degreeso the active path proceeds cleanly without deadlocking.
- When a
- Completion vs. Early Finish:
- Reaching Workflow Output records
_workflow_outputand completes its branch naturally. - Reaching Finish triggers graceful early termination: it records
_finish_messageand_workflow_output, sets the requested status (Completed,Failed, orCanceled), and cancels any remaining in-flight tasks.
- Reaching Workflow Output records
Complete Annotated Diagram Example
{
"entry": "in_1",
"nodes": {
"in_1": {
"type": "trigger_input",
"next": "http_1"
},
"http_1": {
"type": "activity",
"activity": "http_request_activity",
"config": {
"method": "GET",
"url": "https://api.example.com/v1/customers/{{customer_id}}",
"output_key": "customer"
},
"next": "cond_1"
},
"cond_1": {
"type": "switch",
"expression": {
"path": "customer.tier",
"op": "==",
"value": "enterprise"
},
"branches": {
"true": "llm_1",
"false": "finish_skip"
}
},
"llm_1": {
"type": "activity",
"activity": "llm_activity",
"config": {
"provider": "vertex_gemini",
"model": "gemini-2.5-flash",
"secret_name": "gemini_prod_key",
"prompt_source": "template",
"prompt_template": "Write a VIP welcome note for {{customer_name}}.",
"output_key": "welcome_note"
},
"next": "out_1"
},
"out_1": {
"type": "terminal",
"config": {
"payload_source": "specific_key",
"payload_key": "welcome_note"
}
},
"finish_skip": {
"type": "terminal_finish",
"config": {
"termination_type": "Completed",
"message": "Skipped non-enterprise account."
}
}
},
"wires": [
{ "from_node": "__initial__", "from_key": "customer_id", "to_node": "http_1", "to_key": "customer_id" },
{ "from_node": "http_1", "from_key": "customer", "to_node": "cond_1", "to_key": "customer" },
{ "from_node": "__initial__", "from_key": "customer_name", "to_node": "llm_1", "to_key": "customer_name" },
{ "from_node": "llm_1", "from_key": "welcome_note", "to_node": "out_1", "to_key": "welcome_note" }
]
}
Validation Modes
Every diagram passes through two validation modes before saving or running:
AuthoringDraft: Permits work-in-progress settings (such as a missing BYOK secret or unconfigured webhook secret) asWarningdiagnostics while blocking structural errors (unknown node types, cycles, disconnected ports, or quota limits).StrictRunReady: Promotes missing required settings, unresolved Secrets Vault references, missing Agent Skills, or invalid Dataset scopes into blockingErrordiagnostics before a run can start.
See How Data Flows Between Nodes and Expression and I/O Rules next to learn how values travel across edges and how each node reads them.