What is agent state?
Agent state is the structured data an AI agent's harness keeps about a task in progress, such as the current step, collected inputs and pending approvals, stored outside the model so a run can be checked, paused and resumed.
Checked
An agent's history says what was said. Its state says where the task stands: which step it is on, what has been collected, what is waiting for approval. Keeping the two apart is what lets an agent stop for a day and resume without guessing.
Google's ADK post on long-running agents (2026-05-12) gives the clearest case for it. Replaying a full history after a long pause pollutes the prompt, costs tokens, and leads the model to hallucinate intermediate steps that never happened. Its fix is explicit state, not a bigger context window.
State as a state machine
Google's onboarding example tracks progress through named checkpoints: start, welcome sent, documents signed, IT provisioned, hardware delivered, completed. Each tool writes its checkpoint to persistent session state, so a crash just after a tool runs does not lose progress, and the current step is injected into the system instruction on every call.
When an external event arrives, such as a signed contract, a webhook resumes the agent with a state change that advances the step before the model is called. The post says the agent cannot skip a step or hallucinate progress because the state machine enforces the sequence, and its evals include a case where the agent is asked to provision accounts early and must refuse.
Scopes of state in ADK
ADK's session state is a key-value store whose key prefix sets its scope. Unprefixed keys belong to one session; user-prefixed keys are shared across a user's sessions; app-prefixed keys are shared across all users; temp-prefixed keys last for one invocation and are never persisted. State can be templated into instructions by key.
The documentation is strict about how state changes: through an agent's output key, an event's state delta, or the context object inside a tool or callback. Editing a session object directly skips event tracking, may not be saved and is not thread-safe.
Run state for approvals
OpenAI's Agents SDK captures a paused run as a run state object when a tool needs approval. The application approves or rejects each pending call, can serialise the state to JSON to store it, and resumes the run later from that state. The documentation adds two cautions: a restored snapshot is not authenticated, so only trusted snapshots should be loaded, and approval does not guarantee a tool runs exactly once, so consequential tools need idempotency keys.
State, session and memory
Session
The full log of what happened in one run. State is the compact, structured summary of where the run stands, often stored alongside it.
Memory
Facts carried across sessions, such as preferences. State is about the task in progress.
Context
What the model sees on a call. Relevant state is injected into it; the rest stays in storage.
How Motiontic's engineers apply it
Motiontic's engineers model long or approval-heavy agent tasks as explicit states with allowed transitions, enforced in code rather than in the prompt. Tools write state, the model reads it, and evals pre-seed states to test resumes, delayed approvals and attempts to skip a gate.
Session state scopes in Google ADK
| Key prefix | Shared across | Persistence |
|---|---|---|
| None | The current session only | With a persistent session service |
| user: | All sessions of one user in an app | With a persistent session service |
| app: | All users and sessions of an app | With a persistent session service |
| temp: | The current invocation only | Never; discarded when the invocation ends |
Common questions
What is state in an AI agent?
State is structured data about a task in progress, such as the current step, gathered inputs and pending approvals, stored by the harness so the agent can resume and so code can enforce the order of steps.
Why not just keep state in the conversation history?
Long histories are expensive to resend and hard for the model to read reliably. Google's ADK guidance found models hallucinate steps after long pauses when relying on history, and recommends explicit state.
How do agents pause for human approval?
The harness saves the run's state with the pending action, waits without using compute, and resumes from that state once a person approves or rejects. ADK and the OpenAI Agents SDK both support this.
Related
Session (AI agents)
The durable log of a run, kept outside the window, that every prompt is built from.
Human in the loop
Approval gates where a person decides, placed by risk rather than on every step.
Durable execution
Runs that survive crashes and pauses because every finished step is recorded.
Long-running agent
Agents that work for hours or days, and the state that lets them pick up where they stopped.
AI agent development
Agents that do real work for users, with the evals, traces and guardrails to keep them in production.
Running agents that have to hold up?
Describe the agent, the systems it touches and what it must never get wrong. The first call is with a lab engineer, who will say plainly whether it is ready for production, and whether Motiontic is the right team.