AI CompendiumA public chart of the language
Home / Tokens & Context / Stateful
Tokens & Context

Stateful

Something that carries information forward — the app, usually, not the model.

Definition

A system that preserves information across interactions. Chat applications are stateful because they store and replay the conversation; the underlying model is not.

Some hosted APIs now offer server-side conversation state, but conceptually the state still lives outside the weights. The model itself never updates from your usage.

The distinction to hold on to: statefulness belongs to the application and the harness, not to the model. Products that feel like they remember you are doing it by storing history and replaying it — and the quality of the illusion depends entirely on how well they edit that history.

How people use it
Choosing where to store chat history.
"We are the stateful layer. Keep sessions in Postgres and decide what to replay into context."
Worked example

Sessions as recoverable state

A long-running agent must survive a restart without losing its place.

Keep the session log durable and external so the model and harness can be replaced underneath it. That separation is what lets work resume after a crash instead of restarting from the original prompt.

Sources
  • blogScaling managed agents: decoupling the brain from the hands ↗Anthropic Engineering · 2026

    Separates model, harness, durable session log and execution sandbox — the architecture that makes long-running agents survive crashes and tool boundaries.

  • docsAgents ↗OpenAI API docs · 2026

    Compares a managed hosted agent, an in-app SDK loop, and the raw Responses API, including sessions, handoffs, approvals, sandboxing and compaction.

Related terms