subagent-dag-orchestration
Use when delegated work breaks into several tasks that agents on the roster can carry out. The host's role decides what to delegate; this skill decides how to group that work. A DAG node dispatches to a roster agent, including the generic agent, and cannot call the host's tools. Choose from the tool's `subagent` parameter enum -- agent names on ordinary turns, worker labels when a Worker Table is
Install
Copy this folder into your Claude Code project (needs Node.js):
npx degit EverMind-AI/Raven/raven/memory_engine/skills/subagent-dag-orchestration .claude/skills/subagent-dag-orchestrationOr install it for every project:
npx degit EverMind-AI/Raven/raven/memory_engine/skills/subagent-dag-orchestration ~/.claude/skills/subagent-dag-orchestrationFile content
Made by its original authors and shared under Apache-2.0. We show it unchanged, with credit and a link to the source. Source β
---
name: subagent-dag-orchestration
description: Use when delegated work breaks into several tasks that agents on the roster can carry out. The host's role decides what to delegate; this skill decides how to group that work. A DAG node dispatches to a roster agent, including the generic agent, and cannot call the host's tools. Choose from the tool's `subagent` parameter enum -- agent names on ordinary turns, worker labels when a Worker Table is bound. The roster describes underlying capabilities. Reading a brief or checking task status is host coordination, not a reason to create graph nodes. Before dispatching tasks one at a time, test three things: are two or more tasks independent (they can run at once), does a task hand its result to the next (a graph wires that handoff with no turn of yours in between), do the tasks want different specialists (the roster closes the tool list). If any of the three holds, orchestrate the whole task as one run_subagent_dag call. A step whose result decides what runs next is a decision node: give it routes, and guard what follows with when, all in one graph. Iteration is graphs in series, one graph per round, driven by you.
metadata: {"raven":{"emoji":"πΈοΈ","always":true,"inject":"description","requires":{"tools":["run_subagent_dag"]}}}
---
# Sub-Agent DAG Orchestration
## When to use
The trigger is **delegated work that breaks into several tasks**.
The host's role decides what to delegate; this guide decides how to group the work.
A DAG node dispatches to an agent on the roster, including `Raven-General`; it cannot
call the host's tools. Choose from that tool's `subagent` parameter enum: agent names
on ordinary turns, worker labels when a Worker Table is bound. A worker label selects
the underlying agent together with that worker's brief. The roster describes the
underlying agents' capabilities; its names are not dispatch values on a worker turn.
The host's own coordination calls, such as reading a brief or
checking task status, are not delegated tasks and do not need a graph just because
there are several of them.
For the delegated tasks, test three things before dispatching them one at a time:
- **Independence** β can two or more steps run at the same time? Independent nodes are
scheduled concurrently, up to the shared sub-agent cap
(`max_concurrent_subagents` β `spawn` draws on the same allowance).
- **Handoff** β does a step hand its result to the next one? A node's output is written
to a file the downstream node reads, and the graph wires that handoff itself. A `spawn`
can hand its result on too β it takes a `node_id` and a later task names it the same way
a node does β but only across a turn of yours; a graph needs none.
- **Specialism** β do the steps want different sub-agents? The roster at the end of
the tool list says what each agent is for. When a Worker Table is bound, the
`subagent` parameter also describes each worker's brief; choose a label that fits.
If any of the three holds, express the whole task as **one** `run_subagent_dag` call
rather than dispatching sub-agents one at a time. Persistence is not one of the reasons:
every node's prompt and output is written to disk, and so is every `spawn`'s.
**Iteration is graphs in series, not a cycle in one graph.** A graph is acyclic and
runs once. When the work loops β code changes feeding experiment rounds feeding the
next code change β dispatch one graph per round and drive the loop yourself: each
graph's outputs come back to you, and the next round's nodes reuse the same
`instance` handles, so each side keeps its context across rounds.
If none of the three holds, dispatch the work to one agent: use `spawn` if it is offered,
or a one-node graph if `run_subagent_dag` is the only dispatch path. The host's role still
governs the work; choosing one agent instead of a graph does not change that role.
Every install can run a graph: raven's own agents are on the roster whether or not any
third-party agent is configured, so `run_subagent_dag` is always available. Which agents
exist is still the roster's answer, not this file's β read it at the end of the tool list.
Use the current parameter enum to choose which names or worker labels you can pass.
## Write the brief as the owner gave it
A node sees only its prompt. Whatever the owner asked for, and whatever the owner allowed
the node to change, reaches the node only if the prompt carries it -- and the prompt is where
a whole run's search space gets narrowed without anyone deciding to narrow it. Three rules,
each from a measured loss on 2026-09-08, where a two-round search left the one knob worth
most of the result untouched:
- **The owner's words and scope go in as written; your steer is marked as yours.** Quote
the owner's request in every node's brief, not only the first round's. Your own reading of
where the gains are is welcome as a suggestion, and it stays a suggestion: "gains can only
come from ..." is a boundary the owner never drew. That day the owner allowed "training
configuration, data mix, architecture, algorithm"; the round-one brief added "the
hyperparameters are exhausted, so gains can only come from three classes outside the
falsified list", and the round-two brief to the experiment runner opened with "you change
no case". The runner changed nothing in 26 scored runs. One plain training setting, the
kind the runner owned, was worth most of the gap to the best known result. It was never tried.
- **A list of tried things stays a list; it does not become a category.** When a handover
names settings already swept, pass the list itself and ask the node to check what is *not*
on it before it picks directions. Eighteen named hyperparameter groups became "the
hyperparameters are exhausted"; the setting that mattered was on neither.
- **Each role's brief states the whole of its role, not this round's chores.** If the owner
gave the experiment runner the training configuration, the runner's brief says so every
round, whether or not you expect it to matter this round. A duty left out of the brief is
a duty the node takes to be someone else's.
## How it works
You submit a flat list of `nodes`. A scheduler runs every node whose dependencies are
met, as soon as they are met. Each node's prompt is rendered from its template,
dispatched to its sub-agent, and the reply is written to a file of its own, flat and
keyed by node id rather than nested under the run. Downstream nodes reference upstream
outputs through template placeholders. When the run finishes you get the terminal-node
outputs plus every node's output-file path β as a message once the run ends, or as the
call's own result when you asked for `background: false`.
A node also leaves a **memory record**, `<node>.memory.json`, if its sub-agent runs on
a long-term memory backend: what that sub-agent distilled from the call into its own
memory, as `{"agent", "status", "memories": [{"type", "text"}]}`. This is separate from
its output file β the output is its answer to you, the record is what it concluded for
itself. Every node is told the paths of its upstream nodes' records automatically, so
you do not pass them: see `Upstream memory records` below.
A DAG run has no timeout β a long run is ended by hand (manual stop), not by a clock.
## Background by default
The call returns as soon as the graph is accepted, naming the run:
```
DAG run 20260729T031500Z-1a2b3c4d started in the background (3 nodes). I'll report the
result when it finishes -- keep working, and do not submit this graph again.
```
The graph keeps running after your turn ends, and its full result is delivered to you as a
new message when it finishes β the same way a `spawn` reports back. One other message can
reach you before that one: a node that could not do its job asking you what to do about it
(see below). So:
- **Don't** re-submit the same graph, and don't call the tool again to check on it. There is
nothing to poll; the result comes to you.
- **Do** carry on with whatever else the task needs while it runs.
- Tell the user the work is under way, without promising the outcome you have not seen yet.
Pass `background: false` only when you genuinely cannot continue without the outputs β for
instance when the very next thing you must do is read them. That blocks your turn until the
graph finishes, or until a node reports it could not do its job, whichever comes first. In the
second case the call returns that node's report instead of the summary; see below for what to
do with it.
A malformed graph is rejected in your own turn either way, before anything is dispatched, so
a call that returns "started" has already passed every check.
A stopped run reports nothing back β if the user cancels it, no announcement arrives.
## When a node cannot do its job
Finishing is not the same as succeeding. Every node's answer is judged against the task it
was given, so a sub-agent that ran to the end and reported it could not do the work -- a
missing credential, a missing piece of the request, a tool that kept failing -- does not
count as done. Its output is withheld from the nodes that depend on it, and you get a
message naming the node, what is missing, and which downstream nodes are blocked behind it.
That message arrives mid-run, not at the end. The rest of the graph keeps going: only the
nodes that depend on it wait.
Answer it by calling `resolve_dag_node` through `tool_call`: it is not in your tool list,
and `tool_call` is the only way to name it. The report you receive carries that tool's
complete schema and a copyable invocation, so take the field names from there and not from
this page. What follows is what the four decisions mean, not how to spell them.
- `continue` sends your message to the node and lets it try again, keeping the graph and
everything it has already done.
- `abandon` gives up on that node. Its dependents are skipped; every node that does not
depend on it finishes normally.
- `replan` replaces what is left of the graph: this run stops and a new one starts from the
nodes you supply. Nodes this run completed are referenced (`depends_on` plus
`{{ <id>.output }}`), never re-declared; every other node needs a new id, including a redo
of the node that failed.
- `reassign` hands the node to another sub-agent on the roster. The node keeps its id, its
task and its place in the graph -- its next attempt runs on the agent you name, called
`agent`, which is a roster name rather than a worker label. On a run dispatched from a
Worker Table a roster name takes the node out of that table: it keeps the charter of the
role it was submitted under. That agent's first prompt
carries a **handover** of the visible conversation so far -- what was asked and what it
answered, as plain text -- followed by the message that attempt would otherwise have been
given. When the node runs on an `instance`, the handover is the instance's whole
conversation, and whichever moved node reaches the new agent first plants it -- not
necessarily the node you answered -- each mover then following it with its own prompt. The
handover leaves out everything the old agent did with its tools -- there are no tool calls,
no tool output and no private context of that agent -- so say what went wrong in your
message.
The report's invocation looks like this, with the values filled in:
```json
{"run_id": "<run id>", "node_id": "<node id>", "decision": "reassign",
"agent": "<roster name>", "message": "<what the new sub-agent should do>"}
```
**Choosing between them:** when you can supply what the report says is missing, `continue` --
and if only the user can supply it -- a credential, a decision, a fact about what they want --
ask them first and then continue the node with their answer, because that is the case this
whole mechanism exists for and abandoning instead throws away work one sentence could have
unblocked. When the sub-agent lacks what the task needs -- a tool, access to the files, a
skill, or the strength for it -- `reassign`, choosing by how well the roster's descriptions
and tags fit the task; an agent that already tried the node is not excluded, because a failure
may have been chance. When what is missing is the plan itself, `replan`. `abandon` is for work
that turns out not to be needed. Replanning because a node is hard is how a graph loops
without progressing -- each replan starts its nodes on a fresh attempt budget, and the only
thing that stops the loop is the session's hourly dispatch limit.
A `reassign` spends a continuation, like `continue`, and the attempt budget is not reset.
When the node runs on an `instance`, the run's other unfinished nodes on that instance move
to the same agent; a node running at that moment finishes its attempt first and joins only if
that attempt lands unfinished. When more than one node of the run shares the instance, the
target must be tagged `[stateful]`, and the instance moves with the node. A node that already
finished keeps the agent that did the work.
Three cases are worth planning for. A target `agent` that already has a conversation under
the node's named `instance` in this conversation is refused -- choose another agent, or replan
with a new instance name. A run submitted with `confirm: true` asks the user again before the
reassignment, naming each node that would move, and a refusal records no decision. And when
either the old or the new agent runs on a registered machine, the files the earlier attempts
wrote stay where they were made: the result says so, and your message has to carry what the
new agent needs.
Two limits worth knowing. A node gets a small number of continuations before it fails for
good, so a message that does not actually change anything wastes one. And the run does not
wait forever -- if nobody answers, the node fails on its own and its dependents are skipped.
In a `background: false` call the report does not arrive as a message: it is the call's own
return value, and the graph keeps running while you read it. Answer it the same way, with
`resolve_dag_node` -- which, for a blocking run, waits and returns the next report or the
final summary, so keep calling it until you have the summary. While your turn is running the
graph waits for you without a deadline; ask the user first if only they can supply what is
missing. If you end your turn with a report unanswered, the run carries on as a background
run: the report is re-sent to you as a message and the usual deadline starts.
To stop the whole run rather than one node, call `cancel_dag` the same way, through
`tool_call`. That discards the run outright and starts nothing in its place -- it is not
`replan`, which keeps the completed work and chains a successor.
Each run costs one unit of the same per-hour budget `spawn` draws on
(`max_subagent_spawns_per_hour`), whatever its node count. Submitting graphs in a loop
exhausts it and the next call is refused, so express the work as one graph rather than
several.
## Input format
Call `run_subagent_dag` with `nodes`: a list of node objects. The optional `background`
flag (default `true`) is described above.
| Field | Required | Meaning |
| --- | --- | --- |
| `id` | yes | Node id, unique across the whole conversation (not just this graph). Letters, digits, `_`, `-` only. |
| `subagent` | yes | Choose from this tool's `subagent` parameter enum: agent names on ordinary turns, worker labels when a Worker Table is bound. A worker label selects its agent and brief together; pass the label itself. The roster at the end of the tool list describes underlying capabilities, including Raven's in-process agent, so a graph needs no third-party agent configured. |
| `prompt_template` | yes | Template rendered into the node's prompt. May contain the placeholders below. |
| `depends_on` | no | Upstream node ids that must finish before this node runs. May also name a task this conversation already finished β an earlier run's node, or a `spawn` β which only records the dependency. |
| `inputs` | no | Object mapping a key to a literal string, to `{"file": "<path>"}`, or to `{"node": "<id>"}` for another node's output β exactly one of the three, with nothing else in the object. |
| `instance` | no | A stable handle (e.g. `researcher`). Nodes sharing it run sequentially in id order and reuse one sub-agent session β only on an agent the roster tags `[stateful]`. |
| `routes` | no | Makes this node a **decision node**: route name to the condition, in plain words, under which its answer selects that route. See `Conditional branches`. |
| `select` | no | `"one"` (the default where there are routes): exactly one route. `"many"`: any number, none included. Only with `routes`. |
| `when` | no | Guard. This node runs only if it holds once its dependencies settle. See `Conditional branches`. |
A handle reaches beyond one run: two graphs in the same conversation that name the same
handle share one sub-agent session, in whichever order they reach it. Reuse a handle across
runs only when you mean to continue that conversation; give the later graph a different one
otherwise. Omitting `instance` does not mean no session: one is assigned automatically per node
and reported in the run summary when it finishes, so that node can be continued later too.
### Sub-agent capability tags
The roster tags every available sub-agent, and both tags are checked
before any node is dispatched β a graph that violates one is rejected whole, with
nothing run:
- `[stateful]` / `[stateless]` β only a `[stateful]` agent carries context across
nodes that share an `instance` handle. Sharing a handle on a `[stateless]` agent
is rejected: there it would only serialize the nodes while each still starts from
scratch. Pass what the later node needs through a placeholder instead. `spawn`
refuses an `instance` on a `[stateless]` agent for the same reason.
- `[local-files]` / `[no-local-files]` β a `[no-local-files]` agent runs where this
filesystem is not, so handing it a path is rejected. Give it the *contents*
(`{{ <dep>.output }}`, `{{ inputs.<k> }}`, `{{ ref:<path> }}`) instead of the
`_path` forms.
### Template placeholders
Inside `prompt_template`:
| Placeholder | Resolves to |
| --- | --- |
| `{{ <id>.output }}` | That node's output **contents**. |
| `{{ <id>.output_path }}` | That node's output file **path**. |
| `{{ inputs.<key> }}` | The input's literal value, or the **contents** of the file or node it names. |
| `{{ inputs.<key>.path }}` | That file's, or that node's output file's, **path**. |
| `{{ ref:<path> }}` | The **contents** of an existing file. |
| `{{ ref_path:<path> }}` | That file's **path**. |
Rules:
- **Prefer the `_path` forms for anything large.** They hand the sub-agent a path so it
reads the file itself β the bytes never enter your context. Only for an agent tagged
`[local-files]`; a `[no-local-files]` one has to get the contents form.
- A `_path` form must name a file that already exists. One that does not fails the node
before its sub-agent is dispatched, rather than handing over a path nothing can open.
- `{{ inputs.<key> }}` needs `<key>` declared in that node's own `inputs`. The key is
never a node id; what may name a node is the *value*.
- And the other direction: every key declared in `inputs` must be referenced by a
placeholder. Material reaches the sub-agent only where a placeholder puts it, so a
declared key nothing references would not arrive at all β the graph is rejected rather
than run with material that silently went nowhere.
### Node ids are unique across the conversation
**A node id may not repeat an id anything in this conversation already used** β an earlier
run's node or a `spawn`, which takes its `node_id` out of this same namespace. The graph is
rejected if it does. That is what makes `{{ <id>.output }}` mean one thing, so pick ids that
say what the node produced β `pricing_research`, `deck_script_v2` β not `a`, `step1`, or a
generic `plan` you will want again. Re-doing work needs a new id; the earlier node's output
stays where it is and stays referenceable.
### Reading a task this conversation already finished
Because ids are unique, **an earlier task is named by its id alone** β and it does not
matter which tool ran it:
```
{{ pricing_research.output }} that task's output text, whichever run or spawn produced it
{{ pricing_research.output_path }} its path
```
The same works in the other direction: a `spawn` takes a `node_id` and can name a node this
graph leaves behind, with the same three forms.
That task needs no `depends_on` β there is nothing to order, it has already finished.
Listing it anyway is accepted and changes nothing, so write the edge if it makes the graph
read better. `depends_on` is still *required* for a node of *this* graph, since that edge
is what makes the upstream node run first.
Only a task that **completed and wrote an output** can be named this way, in a placeholder
or in `depends_on` alike. One that failed, was cancelled, was skipped, was not executed, or
is still running keeps its id β nothing else may take it β but has no output
to read, and naming it is refused before any node of your graph is dispatched. The refusal
says which case it is, because the fix differs: re-do work that failed, was cancelled or
was skipped under a **new** id; carry on without a node a branch did not execute, or re-do
that work under a new id too; where the run recorded no outcome for the node at all, read
its file directly; and for a node of a run still in flight, submit again once that run
reports its result.
That last one inverts when you are replanning. A replan discards what is left of the run it
replaces, so a node of that run which has not finished β one still waiting to start, or one
suspended on a report of its own β will never write an output, and waiting for it is waiting
for something the replan itself cancels. Those refusals say so, and ask for a new id: the
same answer this guide already gives for every node of the replaced run except the ones it
completed.
Note what is *not* an option in any of these: re-creating that node here. Its id is
taken, so a graph that repeats it is refused for the reuse instead. Re-running an upstream
step *as a node of your own graph* only works for one that does not exist yet β naming the
taken id in `depends_on` does not re-run anything.
A node id is all you ever need to name a node β there is no run qualifier on these forms,
because there is nothing left to disambiguate. The id also reaches beyond this tool: a
`spawn` takes a `node_id` out of the same namespace, so a graph may name a task a spawn
finished and a spawn may name a node this graph leaves behind. Two other ways to say the
same thing:
```
inputs: {"prev": {"node": "pricing_research"}} then {{ inputs.prev }} / {{ inputs.prev.path }}
{{ ref:@nodes/pricing_research.out.md }} by file path
```
Use the `{"node": ...}` input form when one upstream feeds several placeholders. Use
`ref:@nodes/<node_id>.<ext>` when you have a path rather than an id β it also reaches a
node's other files, not just its output (`<node_id>.prompt.md`, `<node_id>.memory.json`).
`graph.json` and `manifest.json` stay run-scoped rather than moving into `nodes/`, and
anything written before this conversation's history was flattened stays where it was
written β both need the full absolute path described below, not a prefix.
### Where a reference may point
`ref:` / `ref_path:` / `{"file": ...}` paths resolve inside two roots β the **session
working directory** (what a plain relative path is relative to) and **this conversation's
sub-agent history**, which may be named by absolute path. Anything outside both is
rejected, as is a `@nodes/` path that climbs out of this session's node artifacts.
The second root is this conversation's own record: every task it has run, from either
tool, since a `spawn` writes into the same `nodes/` root a graph does and is named the same
way. It stops there. The user's long-term memory, the installed skills, and every
*other* conversation's transcript sit outside it and are refused β so reference an earlier
run's outputs, or files the user pointed you at.
### Upstream memory records
Every node whose sub-agent can open local paths gets this appended to its rendered
prompt, listing each **transitive** upstream and the path of that node's record:
```
## Upstream memory records
- research: <session history>/nodes/research.memory.json
- audit: <session history>/nodes/audit.memory.json
```
Three things follow, and getting any of them wrong wastes a node's turn:
- **You do not write this.** It is appended for you. There is no placeholder for it and
no `inputs` key to set; adding one duplicates what is already there.
- **Paths, not contents.** The node opens them itself with its own file tool. A
sub-agent the roster tags `[no-local-files]` gets no block at all, because a path it
cannot open is noise.
- **A listed file often does not exist yet.** A record is written after its node
finished, by a poller that waits for the memory backend to finish distilling, while
the scheduler starts the next node as soon as its dependencies complete. So absence is
the normal case, not a fault: a node that finds the file missing, or carrying
`"status": "pending"`, should carry on without it. Do not add a node whose only job is
to wait for one, and do not treat a missing record as a failed upstream.
## Conditional branches
One graph can decide where it goes next. Reach for this when what runs next depends on
what a step concludes β a triage that settles whether an issue needs a code fix, a design,
or only an answer; a scan that finds something and a review that only makes sense if it
did. Without it the run has to finish, you read the result, and you submit a second graph,
which costs a turn and a charge on the hourly dispatch allowance.
Three fields do it. They are independent: a node may be a decision node, guarded, both,
or neither.
| Field | On | Meaning |
| --- | --- | --- |
| `routes` | a decision node | Route name to the condition, in plain words, under which its answer selects that route. |
| `select` | a decision node | `"one"` (the default) or `"many"`. How many routes one answer may select. |
| `when` | any node | Guard. A boolean expression over what the decision nodes before it chose. |
**The judge picks the route, not the node.** `routes` makes the node a *decision node*.
Once it finishes, Raven's judge β the same call that decides whether the node accomplished
its task β reads the node's answer against your conditions and selects the route. The
conditions are shown to the judge and never to the node, and a route the node names in its
own text is evidence like the rest of its answer, never the selection.
Two rules the graph is refused for, so write to them the first time:
- **Route names** use the node-id charset β letters, digits, `_`, `-` β and are matched
exactly; two names of one node may not differ only in case. `done` is reserved in any
letter case and cannot name a route.
- **At least two routes** when `select` is `"one"`, at least one when it is `"many"`, and
no condition may be blank.
Two more that no check enforces, and that the judge's reading depends on:
- **A decision node's prompt asks for the conclusion, explicitly.** "Conclude in one
sentence whether this is a defect, a feature request, or a usage question" gives the
judge something to read the answer against. Note what that asks the node for: its
conclusion, not a route name.
- **The conditions are mutually exclusive and decidable**, and a `select: "one"` decision
node gets a catch-all route for everything else, so every answer the node could give selects
exactly one route. Make that catch-all one route whose condition is "anything else", and
name it in the node's `routes` alongside the specific ones. Without it, an answer that
fits none of the conditions leaves the judge no right route to report, and it is held to
the routes you declared: it may pick the nearest one, which sends the graph down a branch
the answer does not support, or report none, which fails the node. Give a decision node
only a defect route and a feature-request route, and a node that concludes it is looking at a
usage question lands on one of the two, or stops the graph.
**A guard reads only what the node depends on.** `when` names `<node>.<route>` β that
decision node selected that route β or `<node>.done`, which means the node settled,
whatever it chose. Only a decision node of this graph that is in this node's `depends_on`
may be named, and only a route it declares. The atoms are joined by `not`, `and`, `or` and
parentheses; `not` binds tightest, then `and`, then `or`, and the words are lowercase.
Spacing between tokens is free; an atom is one token, written without spaces.
**Every decision node in `depends_on` must appear in the node's `when`.** A node cannot
depend on a decision node and stay silent about it; `<node>.done` is how you say "whatever
it chose". This holds for a decision node that depends on another decision node too β a
nested branch names its parent in its own `when`, like any node.
**Guard the entry node of a branch, and every node of the branch that also depends on
something outside it.** A node whose every in-graph dependency was not executed is not
executed either, so a branch node needs no guard beyond naming any decision node it
depends on. A node of the branch that also depends on something outside it, such as the
decision node itself or a node that runs whichever
route is selected, is not left out that way: unless its own `when` names the branch's
route, it can run when the branch does not, and read the fixed sentence for the input it
missed. Name the route, as `<node>.<route>`, not `<node>.done`, which holds whichever
route is selected; and list the decision node in its `depends_on` if it is not there yet,
since a guard may only read a dependency. A merge node that should run on every route,
like `reply` in the example below, keeps `<node>.done`.
**What a guard decides, and what unknown means.** The guard is read once every dependency
has settled; a dependency that failed or was skipped skips the node first, whatever its
guard would say. True runs the node. False leaves it **not executed** with the reason
`when_false`; unknown leaves it not executed with `when_unknown`. Unknown is not false: a
route of a decision node that was never executed is *unknown*, so `not risk.high` does not
hold when no risk was ever judged β nobody decided. A node the branch left out is never
dispatched, never takes a concurrency slot, and writes no output. One whose every
in-graph dependency was left out ends the same way, reason `upstream_not_executed` β that
check comes first, so `<node>.done`, true whatever the decision node chose, cannot revive a node
with no input left on that path.
**A decision node whose route cannot be established fails.** If the judge cannot be
called, its call fails or times out, or it names no usable route even after two
corrections, the node fails with "The route could not be determined: <reason>", and its
output is withdrawn. There is no fallback route. A decision node that did not accomplish
its task is a different case, handled like any other node: it reports to you, and a
`continue` judges the next attempt afresh, route included. A host with no model to judge
with refuses such a graph at submission instead of running it down no branch.
**Every decision node that completes reports what it selected.** The run's summary counts
the nodes a branch left out (`3 not executed`), each of them carries its reason, and a
decision node carries its `selected_routes`.
**A missing input has a fixed stand-in.** When a node reads a dependency of the same graph
that was not executed β `{{ X.output }}`, `{{ X.output_path }}`, or a node-shaped input β
every one of those forms renders the sentence the runner writes:
```
<This task is not executed and the output is missing, please go on without this output.>
```
So a merge step reads that sentence where the branch it did not take would have been,
and is told to carry on without it. That sentence is not a placeholder you write; it is
what the reference resolves to, and it sits outside the fences a sub-agent's own words
arrive in.
For anything the node has to tell apart, write **one titled block per input that may be
missing**. The runner adds no titles of its own, so the headings are yours:
```
## Bug fix result
{{ fix.output }}
## Design proposal
{{ design.output }}
```
Reach a node that may not run with `{{ X.output }}`, **not** with `ref:@nodes/`. A node
*may not run* when it has a `when` of its own, even `<node>.done`, which holds whichever
route is selected, or when it depends on nodes of this graph that all may not run. A
`ref:`/`ref_path:` placeholder, or a `{"file": ...}` input, whose path names the artifacts
of such a node is refused at submission: a node that was not executed leaves no file, and
the reference would fail while the prompt was being rendered, with a missing-file error
that hides the cause.
This check matches the node id without regard to case on every host, even when the
filesystem distinguishes case, because the session reserves node ids that way.
And when a node reads something that may be missing, Raven tells it so: a note after the
rendered template lists the nodes that may not run and repeats the sentence above. You do
not write that note β it is appended whether or not anything is missing this run, so the
prompt keeps one shape across runs.
### A worked example
The owner asked: "Handle issue 123 β work out what kind of issue it is, do the work it
needs, and draft the reply." What it needs depends on the triage, and how closely the
change has to be reviewed depends on what it touches. One graph, two decision nodes, four
guarded steps:
```json
{
"task_summary": "Handle issue 123",
"nodes": [
{
"id": "triage",
"subagent": "Raven-General",
"node_summary": "Classify the issue",
"prompt_template": "Owner's request, as written: \"Handle issue 123 β work out what kind of issue it is, do the work it needs, and draft the reply.\"\nYour part: read issue 123. Conclude in one sentence whether it is a defect in the code, a request for new behaviour, or something else such as a usage question. Give your reasoning after the conclusion.",
"routes": {
"bug": "the issue is caused by a defect in the code",
"feature": "the issue asks for new behaviour",
"question": "anything else: a usage question, or an issue that is neither a defect nor a request for new behaviour"
}
},
{
"id": "risk",
"subagent": "Raven-General",
"node_summary": "Judge the risk of changing this",
"prompt_template": "Owner's request, as written: \"Handle issue 123 β work out what kind of issue it is, do the work it needs, and draft the reply.\"\nYour part: read issue 123 and conclude in one sentence whether a change would touch authentication, billing or a data migration. Give your reasoning after the conclusion.",
"routes": {
"high": "a change would touch authentication, billing or a data migration",
"low": "a change would touch none of those"
}
},
{
"id": "fix",
"subagent": "Raven-General",
"node_summary": "Fix the defect",
"depends_on": ["triage"],
"when": "triage.bug",
"prompt_template": "Owner's request, as written: \"Handle issue 123 β work out what kind of issue it is, do the work it needs, and draft the reply.\"\nYour part: fix the defect.\nTriage: {{ triage.output }}"
},
{
"id": "design",
"subagent": "Raven-General",
"node_summary": "Write the design proposal",
"depends_on": ["triage"],
"when": "triage.feature",
"prompt_template": "Owner's request, as written: \"Handle issue 123 β work out what kind of issue it is, do the work it needs, and draft the reply.\"\nYour part: write the design proposal for the requested behaviour.\nTriage: {{ triage.output }}"
},
{
"id": "deep_review",
"subagent": "Raven-General",
"node_summary": "Review the change risk",
"depends_on": ["triage", "risk", "fix", "design"],
"when": "(triage.bug or triage.feature) and risk.high",
"prompt_template": "Owner's request, as written: \"Handle issue 123 β work out what kind of issue it is, do the work it needs, and draft the reply.\"\nYour part: review the change for impact on authentication, billing or a data migration.\n\n## Risk assessment\n{{ risk.output }}\n\n## Bug fix result\n{{ fix.output }}\n\n## Design proposal\n{{ design.output }}"
},
{
"id": "reply",
"subagent": "Raven-General",
"node_summary": "Draft the reply to the reporter",
"depends_on": ["triage", "fix", "design"],
"when": "triage.done",
"prompt_template": "Owner's request, as written: \"Handle issue 123 β work out what kind of issue it is, do the work it needs, and draft the reply.\"\nYour part: draft the reply to the reporter.\n\n## Triage\n{{ triage.output }}\n\n## Bug fix result\n{{ fix.output }}\n\n## Design proposal\n{{ design.output }}"
}
]
}
```
Read it the way the scheduler does. `triage` and `risk` have no dependencies, so they run
at the same time. `fix` and `design` wait for `triage`; at most one of them runs, because
`triage` selects one route, and neither does when it selects `question`. `deep_review`
waits for all four and runs only for a bug or a feature that the risk assessment called
high. `reply` is guarded by `triage.done`, so it runs whatever the triage chose β and if the
triage said `question`, both `fix` and `design` were not executed, so `reply` reads the
fixed sentence in both of their titled blocks and drafts the answer anyway.
The routes here are worth copying: three decidable statements written to exclude each
other, and `question` is the catch-all that takes every answer the other two do not cover.
`fix`, `design` and `deep_review` each open a branch, and each carries that branch's
guard. `deep_review` shows the guard rule above at work: it reads `fix` and `design`, but
it also depends on `triage` and `risk`, which run on every route, so nothing leaves it out
with the branches it reads; its own guard is what keeps it off the `question` path.
`reply` merges a decision node and two branches: the decision node is named in its `when`, as
`triage.done`, because it runs whatever was chosen; the two branch nodes are only in its
`depends_on`, since neither is a decision node.
## Examples
The `subagent` values below are placeholders β substitute the names the tool reports
as available. Every prompt opens with the owner's request as written (see `Write the
brief as the owner gave it`); the node's own part follows it.
### Fan-out then aggregate
The owner asked: "Pick a web framework for the new service. Compare the candidates on
benchmarks and on what recent papers say about async runtimes, and recommend one." Two
researchers run in parallel; a writer waits for both and reads their outputs by path:
```json
[
{
"id": "research_web",
"subagent": "Raven-General",
"prompt_template": "Owner's request, as written: \"Pick a web framework for the new service. Compare the candidates on benchmarks and on what recent papers say about async runtimes, and recommend one.\"\nYour part: research recent web-framework benchmarks and report your findings."
},
{
"id": "research_papers",
"subagent": "Raven-General",
"prompt_template": "Owner's request, as written: \"Pick a web framework for the new service. Compare the candidates on benchmarks and on what recent papers say about async runtimes, and recommend one.\"\nYour part: summarize the latest papers on async runtimes."
},
{
"id": "synthesize",
"subagent": "Raven-General",
"depends_on": ["research_web", "research_papers"],
"prompt_template": "Owner's request, as written: \"Pick a web framework for the new service. Compare the candidates on benchmarks and on what recent papers say about async runtimes, and recommend one.\"\nYour part: write the recommendation, merging these two sources.\nWeb findings: {{ research_web.output_path }}\nPaper summary: {{ research_papers.output_path }}"
}
]
```
`research_web` and `research_papers` have no dependencies, so they run at the same
time. `synthesize` runs once both finish; as the terminal node, its output comes back
to you inline. Each node sees the whole request, so the writer knows a recommendation
is wanted and the researchers know what it is for.
### Pipeline with a reused stateful instance
The owner asked: "Write the introduction for our report on multi-agent systems: about
200 words, for readers who know software but not agents." A draft is written, reviewed,
then revised. The same session (`instance: "author"`) carries context from the draft
into the revision. This shape needs an agent tagged `[stateful]`; on a `[stateless]`
one the graph is rejected before anything runs:
```json
[
{
"id": "draft",
"subagent": "Raven-General",
"instance": "author",
"prompt_template": "Owner's request, as written: \"Write the introduction for our report on multi-agent systems: about 200 words, for readers who know software but not agents.\"\nYour part: draft it."
},
{
"id": "review",
"subagent": "Raven-General",
"depends_on": ["draft"],
"prompt_template": "Owner's request, as written: \"Write the introduction for our report on multi-agent systems: about 200 words, for readers who know software but not agents.\"\nYour part: critique this draft against that request, for clarity and accuracy:\n{{ draft.output }}"
},
{
"id": "revise",
"subagent": "Raven-General",
"instance": "author",
"depends_on": ["review"],
"prompt_template": "Owner's request, as written: \"Write the introduction for our report on multi-agent systems: about 200 words, for readers who know software but not agents.\"\nYour part: revise your earlier draft using this critique:\n{{ review.output }}"
}
]
```
## Reading the result
Whether it arrives as the announcement of a background run or as a foreground call's return
value, the summary has the same shape:
```
DAG run 20260729T031500Z-1a2b3c4d finished: 3 completed, 0 failed, 0 cancelled, 0 skipped (of 3).
Run dir: <session history>/mas_dag/20260729T031500Z-1a2b3c4d
Node output files:
- research_web [completed]: <session history>/nodes/research_web.out.md
- research_papers [completed]: <session history>/nodes/research_papers.out.md
- synthesize [completed]: <session history>/nodes/synthesize.out.md
Terminal outputs:
### synthesize
<synthesize's output text>
```
- `Node output files:` lists **every** node with its status and output path (failed or
skipped nodes show `(no output file)` plus an `error:` line). A node a branch left out
is listed too, as `[not_executed]` with a `reason:` line saying which of the three it was,
and a decision node carries a `selected_routes:` line β `(none)` when a `select: "many"`
decision node selected nothing, which is a selection in its own right and not a missing one.
- When a node completed and every one of its dependents was not executed, its output is a
terminal output of the run: on a path the branch cut short, that node's output is the last
word on it.
- Only terminal-node outputs are inlined. To review any other node's work, `read_file`
its output path.
- Each node's `<node>.prompt.md` (the rendered prompt) sits beside its output under
`<session history>/nodes/` β useful when a node's answer looks wrong and you need to
see what it was actually asked. The run dir itself holds only `graph.json` and
`manifest.json`.
- A node may also leave `<node>.memory.json` in that same location (see `Upstream
memory records` below). These are **not** listed in the summary, because a record is
written asynchronously after its node finished and so may not exist when the summary
is composed. `read_file` one directly if you want to know what a sub-agent took away
from its step.
## Anti-patterns
- **Don't** dispatch sub-agents one at a time in a loop when a DAG expresses the work.
- **Don't** turn the host's coordination calls into graph nodes. Nodes carry delegated
work; reading a brief or checking task status is part of managing that work.
- **Don't** call the tool again to check on a background run, and don't re-submit its graph β
the result is delivered to you; a second call runs the whole thing a second time.
- **Don't** reach for `background: false` to "make sure it finishes". It finishes either way;
blocking only costs you the turn.
- **Don't** inline large upstream content with `{{ <id>.output }}` when you only need to
pass it along; use `{{ <id>.output_path }}` β unless the agent is `[no-local-files]`.
- **Don't** reference a node of *this* graph in a template without listing it in that node's
`depends_on` β a task this conversation already finished is the case that needs no edge.
- **Don't** guess `subagent` names β only names on the roster resolve.
- **Don't** share an `instance` handle across nodes to "keep them in order" on a
`[stateless]` agent β order without shared context is what `depends_on` already gives.
- **Don't** ask a node to print a route marker for the graph to follow. The node's own text
selects nothing: the judge reads its answer against the conditions you wrote, and a
`route: bug` line in that answer is just more of the answer. Ask the node for its
conclusion instead.
- **Don't** repeat the entry guard on every node inside a branch. A node whose dependencies
all lie inside the branch is left out with its entry, so a copy of the guard there says
nothing and is one more line to keep in step when the branch changes. The exception is a
node of the branch that also depends on something outside it, the decision node
included: it needs the branch's route in its own `when` (see `Conditional branches`).