Where Exactly Is an Agent's State Stored?
State machines are becoming a standard component of Agent infrastructure. But where the state is stored determines where determinism comes from.
Josh Rosen raised a question: if you don't use an Agent state machine, you're completely at the mercy of the model's uncertainty. The model decides what to do and when it's done—are you really comfortable with that?
Recently, he followed up on X: Agent state machines are becoming increasingly critical, so where does the state itself live? He listed several locations: the LLM context window, harness memory, the sandbox filesystem, application state objects, persisted graph checkpoints, and orchestrator event history. In reality, it often ends up scattered across multiple places, with no single source of truth.
Someone in the comments added a sharp point: implicit state lives in the context and can't be diffed. Another developer said that the conversation history shows the agent has already changed the configuration, while the sandbox still has the old files, and no one raises an alarm. Many bugs where 'the model got dumber' are actually state inconsistencies.
The state machine approach is to move the rules out of the model. The model can request an action, but the software decides whether to allow it. Josh groups existing practices into several categories:
The first: controlling the Agent's internal execution loop. For example, with XState's Stately Agent, reasoning, tool calls, waiting for approval, and error handling all become explicit states. The model writes the response, but the application controls which transitions are allowed.
The second: controlling the workflow. LangGraph's StateGraph, Mastra's createWorkflow, and n8n's visual orchestration chain multiple stages into a graph; if approval fails, the request goes back to draft. LangGraph's checkpointing supports persistence, so it can recover after an interruption.
The third: supervising multiple Agents. OpenAI Symphony monitors the issue tracker, dispatches Codex to do the work, and the state machine manages which tasks can run and what happens after they finish. Pi Missions, meanwhile, embeds scheduling tools directly into the harness via an extended API.
The fourth: modeling the work itself. ThruWire uses AI checkpoint graphs, where each checkpoint has requirements and evidence that must be satisfied. The Agent is free to decide how to do it, and the system evaluates whether the evidence meets the requirements. This differs from execution checkpoints—it stores work state, not execution state.
Why does everyone still build their own? Simple scenarios don't need a general-purpose graph runtime. People who already have a Claude Code or Codex environment don't want to replace the harness. And when existing databases, queues, and schedulers are already in place, integrating directly is less trouble. But the cost is that you may eventually implement checkpointing, distributed locks, scheduling, observability, and crash recovery yourself—rebuilding the infrastructure you originally set out to avoid.
Someone in the comments mentioned Acentric, a self-hosted agent harness that persists every running agent in a database and resumes after a crash. There was also Conductor, Netflix's open-source workflow engine, which defines orchestration graphs in JSON and supports LLM tasks, MCP tool calls, human approval, and durable execution. Goose's oi-kit turns the agentic loop into a state machine; the state belongs to the application, and after loading a session it tries the steps from the beginning.
Someone asked in response: the entire planet is a distributed state system, so isn't it optimal for Agent state to be distributed across different environments? Josh replied: distributed state and a distributed state machine are two different things. A state machine defines the possible states and transitions, and that is very difficult to fully distribute.
Interestingly, Ember Cox's reply: 'Deterministic scaffolding doesn't limit an agent; it makes its life legible.' For a petition awaiting approval, the state is simply open and the answer is null; no clever reasoning can skip past that.
As Agents run longer and grow heavier, a determinism layer will become standard. The question now is: where does your state live—and who has the final say.
发布时间: 2026-11-30 10:00