Expand description
The runtime state + event loop: one single-threaded reactor over child frames, reaped children, executor results, timers, the durable inbox and signals.
State mutation happens only here. Being the single writer is what makes the rest of the runtime reasonable about: no lock ordering, no torn reads, and an answer computed for one caller is computed against one consistent view. Every mutation is followed by a checkpoint decision, so durable state never trails the in-memory state by more than one loop turn.
The other runtime::* modules add impl Runtime blocks for turns, tools,
steps and subagents; this file owns construction, the loop, lifecycle and
the status view.
Structs§
- Counters
- Counters for status/reports.
- Instruction
- The instruction in force.
versionincrements on every change, so a consumer can tell a re-read from a genuinely new instruction. - Pending
Tool - A deferred internal-tool request (answered when its wait resolves).
- Runtime
- Subagent
Record - A subagent registry record, persisted as
subagent/<handle>so a child’s identity and result outlive both the child and this process. - TurnJob
- A queued root/conversation turn, waiting for a worker slot and for its context to be free. One context runs at most one turn at a time, so turns for the same conversation queue behind each other rather than interleaving into the same history.
Enums§
- Pending
Kind - Target
- Who receives a deferred tool’s answer.
Constants§
- ABANDON_
GRACE - Extra grace after the drain deadline before children are abandoned.
- TICK
- The reactor tick.
Functions§
- run_
exit_ code - Map a finished run’s status onto a process exit code, so a caller can tell how a job ended without parsing its output: refusal, budget exhaustion, a missed deadline and an unreachable model each get their own code, and anything still unfinished reports as partial.