0010. Agents are values, not processes
- Status: Accepted (validated at M13.4 with deviations; see ADR-0122)
- Date: 2026-10-29
- Plan: M12, M13
- Review: Designing for many cheap agents
Context
Process-per-agent harnesses are heavy: a 2026 Claude Code bug report counted about 400 MB per subagent process. Measured for the review, an idle Node 22 process takes 43 MiB RSS and 30–36 ms to start, while an agent held as a value (a 256-byte record plus a 4 KiB arena) takes 4.25 KiB and 3–4 µs.
Decision
- An agent is a state value plus pending actions, advanced by
step(state, event)on a worker pool with one thread per core. - Waiting on a model is I/O on one event loop, so a waiting agent costs only its state.
- Forking copies the record and shares the context root; contexts are lists of content-addressed message blobs.
- Tools are shared per repository or runtime (language servers, MCP servers), and workspaces are copy-on-write.
- Native or untrusted code runs in
wasm-hostor a separate process; verified Harness code is contained by memory safety and fuel.
Alternatives considered
- A process per agent — strong isolation, but megabytes and milliseconds per agent, and duplicated tool servers.
- A thread per agent — cheaper than processes, but still a stack and scheduler cost per agent, and no cheap fork.
Consequences
Targets in M13.4: idle agent at or under 16 KiB, spawn or fork at or under 50 µs, at least 90% of shared-prefix tokens served from cache, and tool processes per repository rather than per agent.