Multi-node run flows¶
Reference for the fields and rules that govern a multi-node headless run — a run that walks a graph of prompt nodes connected by routing edges. For the mental model, read How multi-node automations work; for a worked build, Build a branching automation. Triggers (manual / schedule / webhook) are documented under the CLI's Headless runs.
Routing-edge selection¶
After a node runs, the walker collects that node's outgoing edges, keeps only the routing edges, sorts them, and takes the first whose condition fires.
Which edges route¶
An edge routes if its routing name is exactly next or begins with
next.. The routing name is the edge's explicit name, or — if unnamed —
the first :-delimited segment of its derived loc after the source-loc
prefix. Every non-next* edge (documents, depends-on, abstract-of,
…) is ignored by the walker.
Reference (non-routing) edges whose target has content are inlined into the running node's prompt; routing edges are not inlined — the next step's prompt never appears in the current step.
Selection order¶
Eligible routing edges are sorted by three keys, in order:
| Key | Direction | Notes |
|---|---|---|
Edge.priority |
ascending — lower fires first | The schema-wide priority convention. |
numeric <index> from next.<index> |
ascending, numeric | next.2 sorts before next.10 (not lexical). A next with no index, or a non-numeric index, sorts last. |
loc |
lexical | Final tiebreak. |
The walker evaluates the sorted edges in order and takes the first whose condition is true. A routing edge with no condition always fires — put it last in the order to make it the fall-through. If no routing edge fires, the run completes (see How flows end).
Conditions use the same JSONLogic grammar and operators as chatbot edges —
see Edge conditions. An unevaluable condition
does not silently fall through; it fails the run with
EDGE_CONDITION_ERROR.
The message.data.* scope in headless runs¶
Conditions and templates in a headless run read a single merged view under
message.data.*, composed of two sources:
| Source | What it is |
|---|---|
| Trigger payload | The run's input — webhook args, or a schedule's eventData. |
| Run envelope | Structured fields extracted by nodes so far (see extractionSpec), accumulated on the run. |
On a key collision the envelope wins — a fact the flow extracted
overrides a hint the trigger supplied. Keys beginning with __ are
stripped from the view (internal plumbing never reaches conditions or
templates). The stored envelope keys are bare (confidence), but they are
read at the message.data. prefix: a condition references
message.data.confidence, a template renders {{confidence}}.
This extends the chatbot variable scopes documented in
Edge conditions → variable scopes:
in a headless run, message.data.* is the trigger-payload-plus-envelope
view rather than a single chat turn's extraction.
data.extractionSpec¶
A field on a flow node declaring the structured fields to pull from the model's response. Shape:
{
"extractionSpec": [
{ "field": "intent", "description": "what the report is about" },
{ "field": "confidence", "shape": "number" }
]
}
| Key | Required | Meaning |
|---|---|---|
field |
Yes | The envelope key to write. |
description |
No | Guides the model on what to extract. |
shape |
No | The value's type. |
Shape vocabulary (v1):
shape |
Extracted as |
|---|---|
number |
number |
boolean |
boolean |
string[] |
array of strings |
| (anything else, or absent) | string |
Fields are best-effort — none is required, so an extraction may come
back with a field missing if the model didn't find it. Conditions
downstream should tolerate an absent field (test with missing).
Reserved field names, rejected at load time (NODE_LOAD_FAILED):
exceptionandexceptions(and their.sub/[index]paths) — reserved for a future agent-exceptions surface. Same reservation as in Edge conditions → reserved names.- Any name beginning with
__— reserved for runner plumbing.
A node with an extractionSpec cannot also declare
tools — the two are mutually exclusive per node. Neither can
share a node with a script.
data.tools¶
A field listing the tools a flow node may call. A node with tools runs a
bounded tool loop instead of a single text completion.
v1 vocabulary:
| Tool | Cost | Purpose |
|---|---|---|
hadron_read_node |
0 | Read a node the run may access. |
hadron_create_node |
1 | Create a node. |
hadron_update_node |
1 | Update a node (merges data shallowly). |
hadron_task_create |
1 | Open a root team task in the run's own App, attributed to the run. Takes title (required), description, source, owner, assignee, tags, startBy, closeSessionWhenDone; a party is { "worker": … } or { "user": … }. A non-null status or a non-empty parentTaskId is refused BAD_USER_INPUT. |
hadron_log (always on) |
0 | Append a line to the hop's logs. |
hadron_fail (always on) |
0 | Author's deliberate stop → AUTHOR_FAIL. |
hadron_log and hadron_fail are injected automatically; you don't list
them. An unknown tool name fails the node at load (NODE_LOAD_FAILED)
before any model call.
Write-tool arguments. The run-tool write surface is its own schema —
it overlaps the MCP node tools but is not identical, so
follow this list rather than the MCP one. The accepted arguments are
urn, name, content, nodeType (default record), data, seq,
tags, description, abstract (≤ 2000 chars), properties, and
isRunnable. hadron_create_node requires urn + name;
hadron_update_node requires urn.
seq is refused on message nodes. nodeType defaults to record, and a
record (or chat-message) node outside a Channel keeps its seq as
protected conversation order. So a run that passes seq to
hadron_create_node without setting another nodeType is refused
SEQ_PROTECTED, and so is hadron_update_node naming a seq that differs
from the stored one (null included) on such a node. The same applies to
every principal. Not refused: a content edit that names no seq, a seq
equal to the stored one, and a write where both the stored type and the
resulting type are neither record nor chat-message. Retyping an ordinary
node into record or chat-message while it carries a seq (named or
stored) is refused, and so is retyping a message away while changing its
seq. To order ordinary nodes, set their nodeType explicitly when you
create them. A node under a Channel's address is still refused
LOC_PROTECTED first. The rule is
cor:dmo:090:02 (hrn:node:hadronmemory.com:specs:cor:dmo:090:02); the MCP
node tools follow it too (see Mutate nodes).
Two differences from the MCP tools of the same name worth calling out:
- Node addressing is by
urn(a fully-qualifiedhrn:node:org:memory:loc), not the MCP tools'loc+memoryId. hadron_update_nodemergesdatashallowly — the patch's top-level keys win, unmentioned keys survive. (The MCPhadron_update_nodereplaces the wholedatabag; the shallow-merge behavior there lives in the separatehadron_update_node_datatool.)
Access constraints (each call is authorized when it happens):
- Same organization only — a tool cannot reach another org's memory.
- Encrypted memories are denied to run tools.
- Personal / private memories are unreachable unless the run acts on
behalf of a user (
--as-self); an App-identity run has no user and can't pass the class gate.
Loop and cost:
- Each call is a
tool.<name>action; writes cost 1 action, reads and logs cost 0. A denied call fails the runACTIVATION_DENIEDmid-hop. - A hop runs at most
RUN_MAX_TOOL_STEPS_PER_HOPtool steps (default 8). Exceeding the cap isn't an error — the loop ends and the last text stands. - The tool loop runs on the Anthropic, OpenAI, and Bedrock providers. A
provider without verified tool support fails the hop
NO_TOOL_SUPPORT.
A side-effecting tool call is never retried: any hop that has run one is terminal on failure, so a re-delivered run cannot repeat a side effect.
External MCP tools¶
Beyond the built-in hadron_* tools, a node can call tools on an
external MCP server your org has registered. Such an entry is named
mcp__<slug>__<tool>, where <slug> identifies the registered server:
- Register and browse the servers first —
createMcpServerrecords one (org ADMIN/OWNER),mcpServerToolslists the callable tools and theirrunToolName. See Call external MCP tools from a flow. - Cost 1 action per call — there are no cost-0 MCP reads, since an external side effect is unknowable.
- Governed by the policy chain as
tool.mcp__<slug>__<tool>; registration alone grants nothing, and a missing grant failsACTIVATION_DENIED. - Validated pre-LLM against the registry: an unknown slug, a disabled
server, or a tool outside the server's allowlist fails the node
NODE_LOAD_FAILEDbefore any model call. - A tool-level
isError: trueis a result, not a run failure — it returns to the model to react to. Only transport/protocol failures raise a typedMCP_TOOL_*error (MCP_TOOL_NOT_CONFIGURED/MCP_TOOL_UNREACHABLE/MCP_TOOL_ERROR— the last carrying anmcpErrorCodepassthrough — plusMCP_SERVER_DISABLED). - v1 limits: Streamable-HTTP servers only, static-header auth (no OAuth), results flattened to text (non-text blocks omitted).
data.script¶
A script node makes one run-tool call and no model call. Use it for a
hop whose action is already decided, such as sending an alert, so the hop
uses no llm.tokens.
{
"script": {
"call": {
"tool": "hadron_send_email",
"args": {
"to": "ops@example.com",
"subject": "Price alert",
"text": "The price is now {{price}}."
}
}
}
}
| Key | Required | Meaning |
|---|---|---|
call.tool |
Yes | A non-empty run-tool name: any name data.tools may list, including mcp__<slug>__<tool> and ha__<slug>__<op>. An unknown name fails the node at load. |
call.args |
No | An object, defaulting to {}. Anything else (null, an array, a scalar) fails the node at load. |
Rules:
- One body per node.
scripttogether withtoolsorextractionSpecfails the node at load (NODE_LOAD_FAILED), even when the other field is an empty list. A missingcall.toolfails the same way. - Arguments are rendered before the call.
{{name}}and{{a.b}}are filled from the run's merged view, the samemessage.dataview that conditions read. Values go in as-is and are never HTML-escaped. An argument that is exactly one placeholder keeps the value's own type, so a number stays a number. - A missing variable stops the run. A placeholder with no value (absent,
nullor an empty string) fails the run at that node withSCRIPT_VARIABLE_MISSING, and the message names the variable. Nothing is sent and no action is spent. - Governed like a model's call. The call is admitted as
tool.<name>through the policy chain at the tool's own cost, with the tool's own quotas and tickets. A script hop does not pay the one action that entering an additional model hop costs. - The result is the hop's output. A string result is used as is; any other result is serialized as JSON.
- No tokens. A script hop records no
llm.tokensand no usage event. - A throw is terminal. If the tool throws, the run fails
TOOL_FAILEDand is not retried, as for any tool.
The AI configuration is resolved at the first model hop¶
A run needs an AI configuration only when it reaches a node that calls a
model. A run whose every hop is a script node needs none. A run that reaches
a model hop with no configuration available fails there with
NO_AI_CONFIG; the script hops before it stand.
data.output¶
Controls where a node writes its result mid-flow.
| Key | Default | Meaning |
|---|---|---|
writeTo |
runs:<runId> |
Target node loc, in the flow node's memory. Created if it doesn't exist (name from the last loc segment); updated in place if it does. |
mode |
replace |
replace overwrites the target's content; append folds the new content on with a \n\n---\n\n separator. |
Write rules:
- A node writes mid-flow only if it declares
data.output. - The last node to run (the one where no routing edge fires)
writes — with no
outputspec it writes the default run-record atruns:<runId>beside itself, exactly as a single-node run does. A userless run, such as one a webhook starts, writes with the App's own authority, so the App needs write authority at the destination: read-write access to that memory, or a location write grant (setAppMemoryWriteGrant, for example on the prefixruns). If it has neither, the final write failsOUTPUT_WRITE_FAILEDeven when every earlier hop succeeded. The grant is made by a person acting as themselves who manages the App and can also write that memory (a personal or private memory only by its owner). A run started--as-selfwrites as you, under your own write permissions. - Written nodes are
nodeType: record.createdByisrun:<runId>for a userless run; a run started--as-selfcredits the user instead. writeTointo an encrypted or cross-org memory is denied.
Budgets, limits, and failure codes¶
Defaults, each overridable by the named env var (a value ≤ 0 falls back to the default):
| Limit | Env var | Default |
|---|---|---|
| Token budget (whole run) | RUN_DEFAULT_TOKEN_BUDGET |
100,000 |
| Action budget (whole run) | RUN_DEFAULT_ACTION_BUDGET |
50 |
| Run timeout (per attempt) | RUN_DEFAULT_TIMEOUT_MS |
120,000 ms |
| Max hops | RUN_MAX_HOPS |
50 |
| Tool steps per hop | RUN_MAX_TOOL_STEPS_PER_HOP |
8 |
Budget accounting:
- The first hop's LLM call is free (covered at run mint); every additional model hop costs 1 action. A script hop pays only its own call's cost.
- An output write costs 1 action; each write-tool call costs
1. So one interior hop that runs the model and writes output can
spend 2 actions. The action budget (default 50) is the real ceiling;
RUN_MAX_HOPSguards against zero-LLM cycles. - Each LLM call is capped at
min(remaining token budget, 32,000)tokens; the run's token budget decrements by actual spend (tokensIn + tokensOut) per hop.
Per-trigger token and action limits¶
A schedule, a webhook or a manual launch can carry its own token and action
limit for the runs it starts, so one trigger can be held below the platform
default. The limits are server-side inputs named budgetTokens and
budgetActions on the schedule create and update, webhook create and manual
launch inputs, and on the stored schedule and webhook. They are optional.
From CLI v0.32.1 the same limits are flags: --budget-tokens and
--budget-actions on hadron run trigger, hadron schedule create and
update, and hadron webhook create, plus --clear-budget-tokens and
--clear-budget-actions on schedule update (the CLI's form of the explicit
null below). A webhook's limits are set at create; there is no webhook
update. See the CLI reference.
| Rule | What it means |
|---|---|
| Range | A positive whole number no greater than the platform per-run default (the two env vars above) at the moment you save. Anything else is refused with BAD_USER_INPUT, and the message names the current default. |
| Left out | The run uses the platform default, as before. A trigger with no limits behaves exactly as it did. |
| Schedule update | Omitting a limit keeps the stored value. Passing an explicit null clears it back to the platform default. |
| At every launch | The stored value is checked again against the current default and the lower one wins. If an operator lowers the platform default later, an older trigger cannot exceed it. A stored limit never raises a run above the default. |
| Payload values | A webhook or event payload cannot set or change a limit. Limits come only from the trigger as it was saved. |
| Runs already started | Each run keeps the limits it started with; changing a trigger does not touch a run in flight. |
| Not covered | The run timeout and the daily quotas are unchanged and are not set per trigger. |
The plain-language summary shown when someone reviews an automation before approving it states the budgets that would apply (tokens and actions under the current platform defaults, lowered by the trigger's own limits where it has them). The approval does not lock them: a trigger's limits can change without a new approval, so the approval is not a promise of a maximum.
Because the timeout defaults to the message-bus ack window (120 s), keep a flow within it — roughly 3–10 hops in v1. Don't raise the run timeout above the bus ack window.
Failure codes (on AppRun.failure.code):
| Code | Cause |
|---|---|
EDGE_CONDITION_ERROR |
A routing edge's condition was unevaluable. The run never guesses a branch. |
NODE_LOAD_FAILED |
A node's spec was invalid (unknown tool, reserved extraction field, tools+extractionSpec together, script with tools or extractionSpec, a script without call.tool, …). |
MAX_HOPS_EXCEEDED |
The walk exceeded RUN_MAX_HOPS. |
ACTIVATION_DENIED |
An action or tool call wasn't permitted by the run's policy chain / budget. |
AUTHOR_FAIL |
A node called hadron_fail — a deliberate author stop. |
TOOL_FAILED |
A tool handler threw. Terminal — never retried. |
NO_TOOL_SUPPORT |
The run's provider doesn't support the tool loop. |
OUTPUT_WRITE_FAILED |
The result write failed (e.g. denied target memory). |
SCRIPT_VARIABLE_MISSING |
A script node's argument names a {{variable}} with no value in the merged view. The call was not made. |
NO_AI_CONFIG |
The run reached a model hop and no AI configuration was available. Earlier script hops stand. |
LLM_FAILED |
The model call failed non-transiently. |
TIMEOUT |
The run exceeded its timeout (status TIMED_OUT). |
Terminal run statuses: COMPLETED, FAILED, CANCELLED, TIMED_OUT.
Daily quotas: when a launch is refused QUOTA_EXCEEDED¶
If a run would not start and the error says QUOTA_EXCEEDED, the App or its
organization has used up a daily allowance. It is not an outage and
nothing is broken: the counter resets on its own at the next UTC midnight,
or an organization admin can raise the limit now (below). No run was created,
so there is no AppRun and no failure.code to look for.
The refusal's message names which allowance ran out. It names the scope
(the App, or the whole organization) and the counter (runs or tokens), so
you can tell which one to raise. The wording of the message is not a contract;
read it, do not match on it. Match on extensions.code.
The four counters. Each is kept per scope, per UTC day:
| Counter | What it counts |
|---|---|
run.execute |
Run launches. Checked at launch. |
llm.tokens |
LLM tokens spent by runs. Checked at launch. |
sms.send |
Outbound SMS sends. Not part of the launch check. |
email.send |
Outbound email sends. Not part of the launch check. |
Two scopes. Every counter exists for the App and for its
organization. A launch has to pass both scopes for runs and for tokens; those
are the only two counters a launch reads, so QUOTA_EXCEEDED on a launch
always means runs or tokens. Run launches are charged at
launch (App first; if the organization is then out, the App's charge is
given back). Tokens are checked before launch and charged afterwards, so a new
launch is refused once the day's token counter is at or over its limit, and one
run can carry it past the limit while it is running.
A limit of 0 on run.execute or llm.tokens pauses the scope. Every
launch is refused QUOTA_EXCEEDED until the limit is raised. A 0 on the send
counters does not stop launches. Limits are whole numbers from 0 to 2,147,483,647.
The limit you can read is the limit that is enforced, and it stays when the
day rolls over; only the used count resets. Starting values are set by the
platform operator when a counter is first used, so this page gives none: read
your own with quotaCounters.
A different QUOTA_EXCEEDED
The LLM-configuration test also returns QUOTA_EXCEEDED when a
platform-funded test has used the organization's daily token allowance.
That is a test call refused before any model call, not a run launch, and
these counters are not the way to clear it.
Who can see and change a limit. Only an organization admin. A member
who is not an admin cannot read their own App's counters; ask an admin. Two
GraphQL operations, both documented in the
GraphQL reference: quotaCounters reads usage against
limit, and setQuotaLimit sets a limit.
orgRef and appRef take an ID or a full URN, not a bare name. Read the
counters for an organization and one of its Apps (rows are created the first
time you look):
query {
quotaCounters(orgRef: "hrn:org:acme.com", appRef: "hrn:app:acme.com:support-bot") {
scopeKind
action
used
limit
resetAt
}
}
Raise the App's daily run limit to 500 (omit appRef to set the
organization's limit instead; action is one of the four counters above):
mutation {
setQuotaLimit(input: {
orgRef: "hrn:org:acme.com"
appRef: "hrn:app:acme.com:support-bot"
action: "run.execute"
limit: 500
}) {
scopeKind
action
used
limit
resetAt
}
}
appRef must name an App that belongs to orgRef, or the call is refused
NOT_FOUND. An action outside the four, or a limit outside the range
above, is refused BAD_USER_INPUT.
The run record¶
A run carries its live position and a per-hop trail, both visible mid-run.
hadron run get <id> shows the position; the CLI does not print the trail,
which you read through GraphQL, appRun(ref:) { hops }. See
Headless runs.
curNodeUrn— the checkpoint: the next node to execute while the run is live; at completion it holds the terminal result reference. Cancel a run mid-walk and this points at the hop that would have run next.data— the accumulated envelope (extracted fields).hops— the trail; one element per completed hop:
{
"node": "hrn:node:org:mem:flow:classify", // node executed
"edgeOut": "next.1.high", // routing edge taken; null on the last hop
"startedAt": 1720000000000, // ms epoch
"finishedAt": 1720000000500,
"tokensSpent": 250, // tokensIn + tokensOut this hop
"toolCalls": [ // present only on tool hops
{ "name": "hadron_create_node", "ok": true, "ms": 42 }
],
"logs": ["task node created"] // present only when hadron_log was called
}
toolCalls and logs are omitted on hops that produce none. Budgets
(budgetTokens, budgetActions), status, startedAt, finishedAt,
attempts, and failure round out the record.
Related¶
- How multi-node automations work — the mental model behind these fields.
- Build a branching automation — a worked classify-then-branch flow.
- Edge conditions — the JSONLogic grammar, operators, and scopes conditions share with chatbot edges.
- Headless runs (CLI) — triggering, auditing, and cancelling runs.