Graphs
The inner loop of a turn is a compiled Mermaid graph: the model call, the policy gate, the approval suspension, the tool step and the routes between them. The source lives in the comonad.graph setting; an empty value uses the shipped agent loop. A source may hold several named graphs:
%% graph: id names a graph, %% default: id picks the turn's own loop, and %% soft node: instruct lets the model choose a target. Only the default graph runs a turn; the other named graphs remain available to plugins through ctx.graphs.get(id).
The Orchestrator's task_graph, delegate, task_status and resume are ordinary tools in this loop; task orchestration adds no graph nodes. A delegate call spawns each child with the same default graph in its own hidden session, so the child passes through the same gate, authorization, approval, sandbox and trace layers. A task graph is the Orchestrator's execution state, distinct from the tool-execution graph and from the separate plan file.
Graph, policy and executor
- The graph drives the turn.
agent.callsstarts one tool batch,agent.gatemaps the policy outcome onto a route, andEndis reachable only from the model node, so a turn always ends on a model round. - The policy is a pure decision: it returns
allow,confirmorrejectfor a batch and a trace for every call, and knows nothing about nodes or routes. - The executor (
agent.toolsandctx.tools.invoke) verifies the gate's single-useToolAuthorizationbefore any tool body runs.agent.toolshas exactly one predecessor,agent.gate; a custom graph that wires around the gate reaches the executor without a grant and the call is refused. agent.approvalsuspends the run and returns toagent.gate, which re-evaluates the batch: a policy rejection or a user denial wins, while an approval turnsconfirmintoallow.
Configuring
Set graph in the User (~/.comonad/settings.json) or Workspace (<workspace>/.comonad/settings.json) settings file to a Mermaid source. An empty value uses the shipped loop; a source that fails to parse or compile is logged and the shipped loop runs instead. The four native limits in comonad.budget (turns, tools, tokens and wall-clock milliseconds) apply to the turn; the graph engine also keeps an internal node cap so a custom loop cannot spin forever. Plugins register node implementations and routes on ctx.graphs, so a custom graph can use any implementation the loaded plugins provide.
Plugins
Graph is a row in the shipped cordis.yml. Turning graph off leaves the agent with no engine, which the Plugins tab shows as a dependency.