An agent’s state should be one serializable thread of events, and everything you want from an agent operationally falls out of that. Debugging, forking, approval gates, crash recovery, audit trails, and a human-readable UI are not six features — they are six consequences of one design decision.

This is factors 5, 6, and 12 of 12-Factor Agents, which are really one idea stated three ways.

The two states most systems keep apart

What it holdsWhere it usually lives
Execution stateCurrent step, next step, waiting status, retry counts, error countersAn orchestrator’s own database, a workflow-engine table, framework internals
Business stateWhat actually happened: messages, tool calls, tool results, human responsesThe messages array you send to the model

Splitting them is standard infrastructure practice and it is often correct. For agents Dex Horthy argues it’s usually overkill, because execution state is just metadata about what has already happened — and what has already happened is exactly what’s in the context window.

So invert it: engineer the app so all execution state is inferable from the thread. “Waiting for approval” isn’t a status column, it’s the fact that the last event is a request_human_input with no human_response after it.

Some state genuinely can’t go in the context window (session ids, credentials, password contexts). The goal is to minimise that set, not to pretend it’s empty.

What you get

  1. Simplicity — one source of truth.
  2. Serialization — the thread is trivially dumped and reloaded. No ORM for “agent progress.”
  3. Debugging — the entire history is visible in one place, in the order it happened.
  4. Flexibility — new state is a new event type, not a schema migration.
  5. Recovery — resume from any point by loading the thread.
  6. Forking — copy a subset of the thread into a new state id and branch. (This is what Pi (Coding Agent)‘s session trees give you at the harness level, and what --fork in Claude Code does.)
  7. Human interfaces — a thread renders to markdown or a web UI with no extra modelling.

Points 5-7 are why this matters more as runs get longer. See Long-Running Agents and Session Observability and Replay.

The stateless reducer restatement

Factor 12 says the same thing in functional-programming clothes:

next_thread = step(thread, event)
final_thread = foldl(step, initial_thread, events)

The agent is a pure function from (thread, event) to thread. It holds nothing between calls. Every process can die at any moment and the only thing lost is in-flight work, because the thread on disk is the program counter.

Horthy calls this one “mostly just for fun,” and he’s right that it adds no new requirement. But it’s the useful mental test: if you can’t express your agent as a fold over an event list, you have state hiding somewhere, and that hidden state is what will stop you resuming.

The same insight appears in the vault as “the agent forgets, the repo doesn’t” (Loop Engineering) and as the durable-artifacts pattern in Long-Running Agents - Initializer + Coding Pattern. Those put state in files an agent re-reads; the thread puts it in an event log the harness replays. Same principle, different substrate: state lives outside the model, or it doesn’t survive.

Launch, pause, resume

Once the thread is the state, the operational API is small and obvious:

  • Launch — anyone (user, pipeline, cron, webhook, another agent) starts a run with a simple call.
  • Pause — the orchestrating code stops the loop when a long-running operation or an approval is needed, and persists the thread.
  • Resume — an external trigger loads the thread by id, appends the new event, and continues. No deep integration with the orchestrator required.

The gap that actually matters

Pause between tool selection and tool invocation

Horthy’s number-one feature request of every framework. Most orchestrators can pause between turns, but not in the window after the model has decided to call deploy_backend(v1.2.3, production) and before that call executes.

That window is the only place a meaningful approval can happen. Without it you are forced into one of three bad options:

  1. Block in memory (while...sleep) and restart from scratch if the process dies.
  2. Restrict the agent to low-stakes work like research and summarisation.
  3. Give it real power and hope.

Most teams silently pick option 2 and then wonder why their agent isn’t useful. Option 1 is what “human in the loop” means in most demos, and it’s why those demos don’t survive a deploy. Getting this right is the precondition for Human-in-the-Loop as a Tool Call.

Relationship to the harness

Agent Harness lists five ingredients: loop, tools, context management, I/O surface, provider abstraction. This page argues for making a sixth explicit — the thread — because it’s currently smeared across “context management” (what goes in the prompt) and the I/O surface (sessions on disk). They are not the same concern:

  • Context management answers what does the model see this turn.
  • The thread answers what is true about this run, forever.

You compact the first. You never lose the second. Context Window Management Strategies is about the first; this page is about the second.

Where the vault already had pieces of this

The convergence is the tell: three labs and one indie principle-writer all landed on “the run’s state is a durable object outside the model process.”

Concrete implementation: Pi Durable

Pi Durable supplies a useful implementation and a qualification of the thread-as-state model. Its durable state includes transcripts, task checkpoints, submissions, and typed application documents. Transcript and document changes can share atomic storage commits, but execution state is not literally just the model messages array.

After a process death, the application reopens persistent storage and resumes unfinished tasks. Interrupted model requests are sent again; tools rerun automatically only when declared replay-safe. Otherwise, the interruption and saved output are reported to the model. Stable requestId values deduplicate submission retries. One process owns storage at a time, even when many conversations and clients are active.

Loading the thread is not enough to make a remote effect safe

The reducer model explains reconstructable local state. It cannot establish whether a remote charge or deploy succeeded before the process died. Recovery requires replay policy and external idempotency or reconciliation, not just a saved transcript. See Durable Tool Execution.

The framework’s typed documents also make application-state fork policy explicit: inherit the parent’s value at the fork point, its current value, or fresh state. This keeps business state coordinated without pretending all of it must fit in a model context window. The package is experimental as of its October 2026 announcement.