Glossary

Agent state

Everything an AI agent needs to know about where it is in its work, from the current context and plan to its files and long-term memory.

Agent state is everything an AI agent needs to know about where it is in its work: the conversation so far, the goal and plan, what it has already done, the results of its tool calls, the files it has created and what it has learned about the user. The model itself remembers nothing between calls, so state is whatever the surrounding system keeps and feeds back in. How you store, scope and recover that state decides whether an agent can pause and resume, survive a crash, run for days or pick up where it left off next week.

Why agents need explicit state

A language model is stateless. Each request is answered from the prompt alone, and once the response is returned the model retains nothing. An agent appears to remember because its agent loop collects the previous messages, tool results and notes, and sends them back with every call. That collected material is the agent’s state, and every capability people associate with “smart” agents depends on it: following a multi-step plan, not repeating a tool call that already succeeded, honouring a preference the user gave yesterday.

For a short chat, the message list is enough state. As soon as an agent runs for more than a few minutes, works across sessions or shares work with other agents, the message list stops being adequate. It grows past the context window, it vanishes when the process restarts, and it mixes durable facts with scratch work. That is the point where teams start designing state on purpose, which is what separates stateful from stateless agents in practice. The context window is not memory post sets out why a longer message list does not solve the problem.

The layers of agent state

It helps to separate state by how long it needs to live and who needs to read it. Most production agents end up with four layers.

Layer

What it holds

Lifetime

Where it usually lives

Working context

Current messages, recent tool results, the active step

One model call

The prompt itself

Run state

Goal, plan, progress, intermediate results, pending actions

One task or run, minutes to days

A checkpoint store or graph state

Durable workspace

Files, notes, reports and other outputs

Indefinite

A file system or document store

Long-term memory

Facts, preferences and events about users and projects

Indefinite, updated over time

A memory layer

Working context is what the model sees right now, and it is the only layer the model can reason over directly. It corresponds to working memory and short-term memory in the usual memory taxonomy. Everything else has to be selected and loaded into it, which is the job of context engineering.

Run state is the agent’s bookkeeping for one task. In LangGraph this is the graph state, a typed object updated by each node and saved by a checkpointer after every step; the Exabase vs LangGraph memory comparison covers how that persistence differs from a memory layer. In other frameworks it might be a JSON document or a database row. It typically includes the plan from agent planning, a list of completed and pending steps, and any values the agent will need later. An agent scratchpad is a lightweight version of the same idea.

The durable workspace holds what the agent produces and works on: drafts, data files, research notes, logs. These agent artifacts outlive the run and are often the actual deliverable. An agent file system or agent workspace is the usual home.

Long-term memory holds what the agent knows about the world it serves, especially users. It differs from the workspace in shape: facts and preferences that change over time and must be kept current, rather than documents. The agent memory and long-term memory entries cover it in depth.

Designing agent state well

Keep state outside the model. Anything that must survive a restart, a timeout or a handover needs to be written somewhere durable, not just held in the message list. Checkpointing after each step, or running the agent on a durable execution engine, means a crash costs one step rather than the whole run. This matters most for long-running agents and background agents, which no one is watching when they fail.

Make steps resumable and safe to repeat. If an agent crashes after sending an email but before recording that it did, it may send it again on resume. Recording intent before acting, and designing tool calls to be idempotent where possible, prevents duplicate side effects.

Keep the working context small. Loading the whole of the run state, the workspace and memory into every call is the fastest way to context rot. Better designs keep detail outside the prompt and pull in what the current step needs, by searching the workspace or querying memory. Moving material out of the prompt and fetching it back on demand is context offloading.

Scope state to the right owner. A user’s preferences belong to that user, a task’s plan to that task, a project’s files to that project. Mixing them leads to one user’s context appearing in another user’s session, which is a memory isolation failure and often a security issue. Each layer should carry an explicit scope, such as user, tenant, project or run.

Version what changes. An agent that edits files or updates facts should leave a trail: what changed, when, and in which run. This makes debugging possible and lets you undo a bad run with agent rollback instead of restoring a backup that reverts everyone’s work.

Share state deliberately between agents. In multi-agent systems, subagents start with empty context and an agent handoff moves control between agents. Both work better when durable facts and artifacts live in a store all agents can query, so only short references travel between them.

Common state failures

The most familiar failure is the agent that forgets. A user explains their setup, the session ends, and the next session starts from nothing because the only state was the message list. The fix is long-term memory with automatic extraction, so durable facts survive without anyone deciding to save them.

The second is stale state. The agent stored “the customer is on the free plan” and keeps acting on it after an upgrade. State that represents the world must be updated when the world changes, which is why memory systems that resolve contradictions at write time behave better than append-only logs.

The third is state bloat. Every tool result is appended to the run state and sent back in each call until the agent slows down, costs more and reasons worse. Summarising old steps, storing full results as files and keeping only references in the run state all help.

The fourth is lost progress. A long run fails at step forty, and with no checkpoint it restarts at step one, repeating work and side effects. Checkpoints plus idempotent steps turn that into a one-step retry.

The fifth is the unexplained change. A file was renamed or deleted, and nobody can tell which run did it or what it looked like before. State history, recorded per workspace, answers both questions.

A worked example

A team builds an onboarding agent that helps new customers configure a data integration over several days. On day one the customer explains their stack, uploads two configuration files and asks the agent to draft a mapping.

The working context for each turn holds the latest messages and the current step. The run state, checkpointed after each step, holds the onboarding plan with seven steps, which are done, and the ID of the draft mapping file. The workspace holds the uploaded files, the draft mapping and a running log of decisions. Long-term memory holds facts such as the customer’s database type, their preferred naming convention and the fact that their security team must approve any write access.

On day three the customer returns with a question. The agent loads the run state to see it is on step five, queries memory for what is relevant to the question and finds the approval requirement, and reads the decision log from the workspace. It answers in context without the customer repeating anything. When a later run renames a field in the mapping by mistake, the team looks at the workspace as it was before that run, sees the original name and restores it. The customer onboarding use case covers this pattern.

Where Exabase fits

Exabase covers the durable layers of agent state: the workspace and long-term memory, with history. It does not checkpoint your agent’s execution graph; that stays with your framework or a durable execution engine.

A Base is an isolated workspace for one user, tenant, project or agent, created with one API call and scoped with one header. Agents store files, notes and bookmarks in it through Resources, where everything is indexed on arrival so the agent can find its own earlier work by meaning with Deep Search rather than loading it all into context. Notes have version history for their content, so a decision log or report keeps its earlier versions.

Exabase Memory holds long-term facts, preferences and events. You send it conversation content and it extracts what matters, resolves contradictions when facts change and returns only what is relevant to a query, with simple retrieval in about 200ms (creating memories). That directly addresses the forgetting and stale-state failures above, and it keeps the working context small. The agent memory solution describes the full approach.

For state history, enabling snapshots on a Base records the state of every resource over time: name, location, description and deletion state, hourly for the last 24 hours and in six-hour windows up to 7 days. You can query the Base as it was at any point in that window, compare it with now and recover deleted resources (filesystem snapshotting). Snapshots record metadata rather than file content, and they do not reverse external actions. The agent undo solution and the agent context versioning use case show how teams use this to give agents write access safely.

Frequently asked questions

What is the difference between agent state and agent memory?

Agent memory is one part of agent state: the long-lived facts and preferences an agent keeps about users and the world. Agent state also includes the current context, the plan and progress of a run, and the files the agent is working on.

Where should agent state be stored?

It depends on the layer. Working context lives in the prompt, run state in a checkpoint store, files in a workspace or file system, and long-term facts in a memory layer. Keeping these separate makes each easier to scope, size and recover.

How do I make an agent resumable?

Save run state after every step, make tool calls safe to repeat, and keep durable outputs outside the process. On restart, the agent loads its last checkpoint and continues from the next step.

Why not keep all state in the context window?

It does not survive restarts, it grows with every step, and long contexts reduce accuracy and raise cost. Keeping detail outside the prompt and loading only what the current step needs gives better results.

How should state be shared between agents?

Through a shared store that all agents can query, scoped to the task or user. Pass short references between agents rather than copying full context, so each agent loads only what its job needs.

How do I undo changes an agent made to its state?

Keep a history of changes per workspace. With snapshots on an Exabase Base, you can see the workspace as it was before a run, compare it with the current state and recover deleted resources.

What is the difference between a stateful and a stateless agent?

A stateless agent treats each request independently and forgets everything afterwards. A stateful agent keeps context, progress and knowledge between steps and sessions. The stateful vs stateless agents entry compares them in detail.

Related pages: Agent memory, Agent scratchpad, Checkpointing, Durable execution, Agent workspace, Stateful AI, Long-term memory use case, Exabase vs Letta, The case against storing every conversation, Agent memory solution, Long-running agents.

Cut your token spend and give your agent precise context.

Get started in minutes.

Cut your token spend and give your agent precise context.

Get started in minutes.