Skip to main content

Module runner

Module runner 

Source
Expand description

The ReAct agentic loop. RFC 0007.

A turn: assemble the request (system + instruction + transcript + the scoped tool catalogue) → call intelligence → if the model requested tools, run them via MCP and feed the results back as observations; otherwise the text is the final answer. Stopping is a disjunction of cheap checks, each with a distinct TerminalStatus (RFC 0007 §3.4); the loop enforces the step/token/deadline budget. stalled/loop_detected detectors and context compaction are deferred (v2); the Stalled/LoopDetected statuses are defined but not yet produced.

The root agent runs as a subagent process behind the control channel (spawned by main::run_once via supervise_once); the loop body here is identical whether driven by the root or a nested child.

Structs§

LoopInput
The explicit inputs the loop needs, independent of where they came from (CLI Config for once-mode, or a SpawnPayload for a subagent). This is the seam that lets the same loop body run in-process or in a child.
Session
The durable state of an agent session: the scoped tool catalogue, the resource-awareness map, and the conversation transcript — everything that persists across turns. A once-mode / per-event run is a session of exactly one turn (run_loop); a warm continue-session runs many turns over the same transcript (RFC 0008 §spawn-vs-continue), each new event appended via Session::deliver before another Session::run_turn.

Enums§

LoopAbort
A fatal infrastructure failure that aborts the run (mapped to exit 4 / 6 by the caller, RFC 0011). Tool-domain errors are not aborts — they are fed back to the model as observations.

Functions§

run_loop
The agentic loop over explicit inputs — one session, one turn. Used by once-mode (run_root) and a per-event subagent run (subagent::control). self_handler supplies agentd’s in-process self-tools (e.g. subagent.spawn); the loop tries it before MCP. A warm continue-session instead drives Session directly across many turns.