Est.

Stateless vs. Stateful Agent Runtime Tradeoffs

Models forget everything, so the runtime must decide what to remember.

· 9 min read · Updated
Cover illustration for “Stateless vs. Stateful Agent Runtime Tradeoffs”
Agent Runtime Internals · September 29, 2026 · 9 min read · 2,088 words

A large language model has no memory of its own. Every API call receives a set of tokens, runs attention across that full input sequence, produces an output, and then discards every intermediate representation it built along the way. The next call starts with nothing. No trace of the last conversation, no record of a correction made five minutes earlier, no internal note that this user already explained their problem twice. Model weights hold what the system learned during training, frozen at inference time. Anything resembling memory, conversation history, user preferences, intermediate reasoning, has no mechanism to persist between calls on its own.

What chat interfaces present as "memory" is an illusion built one layer up. The application re-sends prior turns as tokens at the start of each new request, so the model reads that history as input text handed to it fresh each time. If asked to recall something from three calls ago, it can only answer correctly if someone handed it that transcript again this time.

This is a deliberate tradeoff, not an oversight. Statelessness is what lets a request get routed to any available instance, what lets compute stay predictable, what lets a fleet of servers scale horizontally without juggling which machine remembers which user. None of that would be simple if the model itself had to carry session state across calls.

The cost appears the moment an agent has to do something that takes longer than one request. An agent asked to refactor a codebase can work productively for a while, then hits the context window limit and loses the thread. The next session, it rediscovers the same files, repeats the same mistakes, and burns the same tokens it already spent once. In a purely stateless setup, the client has to resend the entire conversation history with every request, so token spend climbs with the length of the transcript, whether or not that history is still useful to the answer. The model's statelessness is a design constraint for whatever sits around it, the runtime, not the model.

The stateless-vs-stateful decision is a runtime architecture choice, not a model choice

That framing matters because it changes the question engineers should actually be asking. The distinction between a stateless agent and a stateful agent is a deployment pattern. Both wrap the exact same frozen LLM. What differs is whether the layer around that model keeps an external store and feeds context back into each call.

The 2026 survey "AI Agent Systems: Architectures, Applications, and Evaluation" makes this formal: the agent layer is defined as a runtime that compensates for the model's statelessness by maintaining an external store and projecting it into every call. A stateless agent treats each request as fully self-contained, nothing persists between calls, and whatever it needs has to arrive in the payload that round. A stateful agent keeps context in a durable store and rebuilds it on every call, so the model always sees a current, well-formed view of the task. UFO, built as an agent operating system, follows that pattern directly: it maintains external state and memory across calls, so agents can hold onto context and keep corrections in place without a team rebuilding orchestration logic from scratch. A hybrid agent, the practical production default, wraps a stateless LLM in a stateful runtime that manages session, memory, and tool state on the model's behalf, separating the reasoning step from the state it depends on.

Getting this framing wrong early tends to be expensive later. MLflow's 2026 architectural guidance is direct about it. Decide the state paradigm before writing a single prompt template, because retrofitting session memory into a stateless design requires a structural rebuild. Storage choice, caching strategy, and tracing setup all follow from that first decision. It belongs at the architecture stage rather than somewhere deep in implementation. Ask the question early: is this a system that needs to remember anything past the current request? The answer shapes everything downstream of it.

What pure-stateless runtime buys

Stateless design earns its place for a defined class of work: atomic, high-throughput, or zero-retention tasks where the whole relevant context fits in one request and nothing needs an identity that carries across calls. Classification, extraction, single-shot compliance checks, these are cases where zero retention is a feature, not something to work around. For regulated environments, that property does real legal work. Stateless inference is the only pattern that guarantees the runtime writes no conversation data to disk, which makes it the cleaner option for EU data-residency rules or zero-retention contracts, not merely the cheaper one.

It also wins in places where there is simply nowhere to put a store. Running a vector database and a full orchestrator on a phone, or inside a vehicle, is usually impractical. On-device and edge deployments often have stateless inference as the only workable pattern, because the infrastructure a stateful runtime needs just isn't there.

There's an infrastructure payoff too, separate from any single workload. Stateless designs avoid sticky sessions, shared caches, and a database sitting on the hot path, since no instance needs to know anything another instance handled. Any available server can take any request, which makes horizontal scaling straightforward.

Stateless systems that resend a stable prompt prefix, system instructions, tool definitions, on every call can still benefit from prefix caching. But designs that resend the full, growing conversation on every call lose that advantage. They trade the simplicity of stateless infrastructure for a steadily rising token bill. So the pure-stateless case holds up cleanly for single-turn, bounded work. It starts to strain the moment a task needs to outlive a single request, which is exactly where the next question has to turn.

Where stateful runtime is not optional

Microsoft's STATE-Bench, published in May 2026, gives a sense of how wide that strain can get. Frontier models tested on long-horizon, state-dependent tasks with no external memory score well below what they achieve on short-context work. Genαi's 2026 analysis frames the gap as an architecture problem rather than a model problem, and separate evaluation work, cited in the 2025 AI Agent Index and agent evaluation survey, found that the best stateful systems substantially outperform the best stateless ones on long-horizon software engineering and multi-turn dialogue tasks. τ-bench, which simulates customer-service conversations where users reveal information gradually and sometimes withhold or reverse details, shows the same pattern: a stateless system that has to re-derive everything from the raw transcript loses materially against a system that maintains an explicit belief state about what it already knows. The gap sits in the architecture.

What that looks like day to day is more useful than the benchmark number itself. A stateless support agent asks the same qualifying questions on every contact because it has no way of knowing whether it has spoken to this person before, even when context that would have prevented an escalation already existed somewhere. Corrections suffer the same fate. When a subject-matter expert takes the time to correct an agent's mistake, that correction survives only as long as the current context window, and the next session relitigates the exact same wrong assumption from scratch. Cost compounds on top of both problems: resending the full history on every turn means token spend keeps climbing with transcript length, independent of whatever value the conversation is actually producing.

Stateful runtime addresses all three by moving state behind the API boundary. The client sends a new message with an identifier, the agent loads whatever state applies, processes the message, and updates that state afterward, so payloads stay flat no matter how long the conversation has been running. That structure also opens up workflows a stateless system simply cannot support: an agent can pause mid-task during a slow tool call or while waiting on human approval, then pick back up later with everything still intact. For long-horizon coding work, multi-session investigations, onboarding programs that run over days, that kind of continuity is the only way the task gets done correctly.

The liability side of stateful runtime: what accumulating state costs in production

Persistence is not free, and a fair accounting has to include what it costs to keep. Stateful systems face a set of failure modes that stateless designs never encounter in the first place: stale state left behind by parallel overwrites, partial updates that leave state inconsistent, race conditions on memory shared across threads, prompt drift as accumulated context slowly distorts the agent's behavior, and state that gets lost somewhere across a retry.

The most common version of this in practice is what might be called localized amnesia: session history gets stranded on the specific instance that handled the earlier turns, and when a load balancer routes the next request somewhere else, the agent loses its context. That reads like a memory bug, but it's really a routing problem, and it has a known fix: centralized caching with something like Redis, or pinned sessions that keep a user's requests on the same instance.

Concurrency is harder to patch around. When multiple agent threads write to shared state at the same time, ordinary database isolation guarantees are not enough on their own, and the system needs explicit locking or optimistic concurrency control to avoid corrupting that state. Persistence is what makes state valuable, and it's also what makes errors durable. Without human oversight, a stateful agent can carry a persistent bias or keep acting on corrupted state for an extended stretch, since nothing forces the error to reset the way it would in a stateless design.

None of this is an argument against stateful runtime. It's an argument for treating state as something with real operational weight: backup procedures, migration plans, expiration policies, retention audits, rollback paths. Storage choice, caching strategy, and tracing setup all flow from the state paradigm decided at the architecture stage, and a pure stateless system has no such concerns since it carries no state to manage. The failure modes above are reasons to be deliberate about how state gets structured, which is a problem with a known shape and a known answer.

How to tier state so each layer carries only what it needs to survive

Diagram: Four Tiers of Agent State. Visualizes: Show the four state tiers from MLflow's production guidance as a vertical stack, each with its lifecycle and storage characteristic.

The mistake that causes most of the failures above is treating state as one undifferentiated blob that lives, dies, and gets queried the same way regardless of what it holds. The fix is to separate state into tiers, each with its own store, its own lifecycle, and its own eviction rules.

MLflow's production guidance lays out four such tiers. Run or session state lives only for the duration of a single task or conversation, keyed by something like a session ID combining channel and user, and it dies the moment the session ends. Conversation state spans multiple turns within one interaction, holding the message history and intermediate reasoning an agent needs to stay coherent across a back-and-forth exchange. User state persists across sessions entirely, carrying preferences, past decisions, and account context that should still be there the next time the same person shows up. Long-term memory sits above all three: durable knowledge built up over time, usually embedding-based, queried by similarity rather than by a fixed key.

Letta, formerly known as MemGPT, organizes a similar idea into three tiers rather than four. Core memory stays always in context, functioning much like RAM for the agent's immediate reasoning. Recall memory holds searchable conversation history stored outside the active context window, available on demand rather than carried in every call. Archival memory is long-term storage queried through semantic search, the place facts go once they're no longer needed turn-by-turn but still matter later.

The value of tiering this way is that each layer only pays for what it actually needs to survive. Session state can disappear the instant a conversation ends because nothing downstream depends on it afterward. User state has to survive far longer, so it belongs in a different store with different durability guarantees. Long-term memory needs to be searchable, so it belongs in something built for similarity lookup, such as a vector store. This is also where tiering resolves the compounding cost from earlier instead of merely managing it. Stateless design still earns its place for atomic, high-throughput work where zero retention is genuinely the right feature. For the harder cases, refactoring a codebase over days, investigating an incident across sessions, running a long workflow end to end, the runtime has to carry state, and platforms built for sustained, team-scale autonomous work treat that persistence, and the scheduled execution it enables, as a basic requirement rather than an added feature.

Sources

  1. Stateful vs Stateless AI Agents: A Practical Comparison | Tacnode Blog
  2. The agent that forgets: Stateful vs. stateless AI agents
  3. Stateful vs Stateless Agents: The Architecture - HydraDB
  4. Stateful vs Stateless AI Agent Design Patterns for Production Systems

More in Agent Runtime Internals