Edges
graph.edges says in which order the nodes run.
graph.edges says in which order the nodes run. It is a list read in order, like a program:
edges:
- start: translator # the first node
- parallel: # a group
- in: framing
- fan:
- next: advantages
- next: disadvantages
- out: balance
- end: closing # the last nodeEvery entry is a map with one key. Every key is described in the reference.
The main flow
startis the first entry, and there is exactly one (edge_start), except in the cases below.nextruns a node after the one before it.endis the last entry, and there is exactly one (edge_end), except in the cases below.- The groups (
linear,parallel,concurrent,batch) andreactare entries of the list likenext.
A graph of one node is the start alone, with nothing else: the node runs once and its output is the result.
A graph whose first entry is a group or a react may leave out the start: that entry takes the message of the user,
and no agent_message. A graph whose last entry is a group or a react may leave out the end: nothing runs after
it, and the result is what the nodes send to the final output (assistant_message). A group or a react alone is a
whole graph:
edges:
- parallel:
- in: split
- fan:
- next: a
- next: b
- out: mergeEvery other graph needs its start and its end.
A node may appear more than once in the edges, and each appearance is a run of it. start: a and end: a is an edge
from a node to itself: a runs twice.
What a node sends on (its message.output.node and the media with node: true) is what the next entry receives as
its agent_message and its media. See nodes.
Groups
linear, parallel, concurrent and batch have the same shape: a list of limit, in, fan and out, each
written once and in this order (block_shape, exactly_one).
in(mandatory): the node that runs first. What it sends on is the input of every branch.fan(mandatory, at least one branch): the branches. A branch is a node (next: <id>) or a whole group orreact, so groups can be put inside groups.out(optional): the node that receives the answers of all the branches, packed as one, and whose output goes on to the rest of the graph. A group may have nooutonly if none of its nodes sends its output on (group_out_required); then the group sends nothing on, and the next entry starts when the branches are done.limit: inparallelandconcurrent, how many branches run at the same time; inbatch, how many requests go in each job, the jobs being sent one after the other.
The four groups differ only in how the branches run:
| Group | How the branches run | limit |
|---|---|---|
linear | one after the other | not allowed |
parallel | all together, each as a task of its own | optional: at most limit at a time |
concurrent | all together, at most limit at a time | mandatory |
batch | as batch jobs of the provider, instead of one call each: one job, or several, one after the other, when limit is lower than the number of branches (see models) | optional: at most limit requests in each job |
The branches of a batch are plain nodes, all with the same model: a group or a react among them is an error. They
cannot have tools, MCP servers or skills (batch_tools): the answer of a batch is the last one, so a tool call in it
would never run. For the same reason they cannot have a schema_prompt (batch_schema_prompt): a correction could
never be sent. The in and out nodes of the group do not run in the batch and may have them.
In parallel and concurrent, the first branch that fails ends the run, and the branches still running are stopped.
How the answers are packed
The out node receives the answers of the branches, in the order of the fan, as its agent_message:
-
texts are joined one after the other, each preceded by the node it comes from:
--- from agent advantages --- <the text> -
answers with an output
schemabecome one JSON list of{ "from_node": "<id>", "content": <the answer> }; -
the media of all the branches are passed together.
Branches that give both texts and structured answers cannot be packed: the run fails.
What the nodes of a group send to the final output goes there in the order of the fan.
React
A react is not a group of branches: a controller decides at run time which worker to call.
- react:
controller: planner
max_iterations: 10
structured_output: api
components:
- worker: researcher
- worker: writerAt every turn the controller answers with a fixed structure, which the program asks of its model:
done:truewhen it gives the final answer,falsewhen it calls a worker;next_worker: the worker to call;input: what the worker receives, as itsagent_message;answer: the final answer;reasoning: why it chose this step.
The worker runs, and what it sends on comes back to the controller as an observation for the next turn. When the
controller is done, its answer is the output of the react, delivered as the output of the controller. The
controller is the only link between the workers and the rest of the graph.
- A worker is a node (
worker: <id>) or a whole group; a group is called by the id of itsinnode. Two workers with the same id are an error (duplicate_id). - The program gives the controller the list of the worker ids; what each worker does must be said in the prompt of the controller.
max_iterationsis the most calls to workers. A controller that asks for one more fails the run (react_limit).structured_output(mandatory) says how the structure is enforced:api, by the API of the provider, asschemadoes for a node;prompt, by a-graph, asschema_promptdoes (see nodes), withmax_attempts(default 3, at least 1, only withprompt) counted at every turn. A routing output that is not one JSON value is corrected in its turn; the next turn gets the routing output alone, and the end of the controller counts the corrections of all its turns.- The controller has no tools, MCP servers, skills, blackboard, output
schemaorschema_promptof its own: its output is defined by thereact. Give those to a worker. - A
reactcannot be a worker of anotherreact, nor stand in a group among its workers: the file is refused (react_nested).
Roles
A node has no field that says its role: it is a controller or a worker because it appears as one in a react, and a
plain step anywhere else.