Agentic AI / TECHNICAL PERSPECTIVE

AI Agent State Management: How Agents Finish What They Start

Learn how AI agent state management keeps enterprise workflows reliable, prevents duplicate actions, supports human approvals and helps agents recover safely.

AI agent state managementAgentic AIAgent memoryDurable executionWorkflow checkpointingHuman-in-the-loopIdempotencyAgent orchestration
REFERENCE WORKFLOW04 stages
01Create a work item with an authenticated identity and a unique workflow identifier
02Load verified state, select an allowed next step and persist its outcome
03Pause for missing information or approval; revalidate conditions before resuming
04Execute authorised actions with duplicate protection, reconcile outcomes and close the work item
EXECUTIVE SUMMARY

Key takeaways

  • An agent's conversation history is not a dependable record of which business actions have actually occurred.

  • Store essential workflow progress independently of the language model, with explicit stages and durable evidence.

  • Protect external actions with stable operation identifiers, idempotency and reconciliation; saving a checkpoint alone does not prevent duplicate transactions.

  • Treat human approval as a decision about a specific proposed action, not as permanent permission to act.

  • Choose the simplest state architecture that satisfies the process's recovery, security and operational requirements.

01 PRACTICAL GUIDANCE

The agent worked yesterday. Can it continue today?

Imagine a finance team introducing an AI agent to process supplier invoices. The agent reads an invoice, checks the purchase order and prepares a payment request. Because the amount exceeds the company's approval threshold, it stops and waits for a manager. The manager returns the following morning and approves the request.

What should happen next? The agent needs to know which invoice it was working on, which checks have passed, exactly what the manager approved and whether the payment request has already been submitted. It must also determine whether anything important changed overnight. If the application restarted during the wait, none of that information should disappear.

Now imagine that the payment service accepts the request but the network connection fails before returning a confirmation. Should the agent try again? Without a dependable record and a way to check the payment service, a retry could create a duplicate request.

These problems are not solved simply by choosing a more powerful language model. They require AI agent state management: the engineering discipline of maintaining reliable information about a task, its progress, its decisions and its interactions with the outside world. It becomes especially important when an AI assistant moves beyond answering questions and starts performing work.

02 PRACTICAL GUIDANCE

State, memory and context serve different purposes

State is the information that determines where a particular task stands and what can happen next. It may include the work item's identifier, completed steps, current status, verified inputs, pending approvals, retry limits and references to action results. It should be structured so that application code can validate and update it.

Context is the information supplied to the language model for a particular inference request. It might contain the current question, selected conversation messages, relevant documents and a description of the permitted tools. The context can be rebuilt from state and other authorised sources whenever the agent needs to think about its next step.

Memory usually refers to information retained to improve continuity, such as previous interactions or a user's permitted preferences. It may be short-lived or persist across sessions. A remembered preference that a user likes concise reports is useful; a remembered sentence saying that a payment was approved is not sufficient evidence of approval.

These concepts overlap in many agent frameworks, but they have different business responsibilities. For example, LangGraph separates thread-specific checkpoints from stores intended for information shared across threads.[1] That separation is useful when designing a system that must maintain task continuity without mixing unrelated customers' information.

The underlying business systems remain authoritative for their records. A workflow can store a reference to an invoice or payment confirmation, but it should not assume that its cached copy always reflects the current position in the finance system.

03 PRACTICAL GUIDANCE

Design the agent's work record before designing its prompts

A useful starting point is to ask what an operations colleague would need to take over the task without repeating completed work. The answer often reveals the minimum information the agent must persist.

Identity and scope: Store a unique workflow identifier, the authorised user or service identity, the organisation boundary, the work-item reference and the approved purpose. A session identifier alone should never grant access to a record.

Progress and evidence: Maintain the current stage, completed checks, relevant document versions, validated tool results and unresolved questions. Store references to large or sensitive documents rather than copying their full contents into every checkpoint.

Decisions and approvals: Record the proposed action, policy version, decision outcome, responsible approver, approval time and any applicable expiry. Distinguish a model-generated recommendation from a verified decision.

Execution controls: Record attempt counts, deadlines, operation identifiers, external confirmation references and error classifications. Set explicit terminal and exception states so a task cannot continue indefinitely.

Use clear data types and permitted values. For instance, an invoice workflow might move through RECEIVED, VALIDATED, AWAITING_APPROVAL, AUTHORISED, SUBMISSION_PENDING, SUBMITTED and RECONCILED. Rejected, cancelled and manual-review paths need their own permitted transitions. An agent can suggest the next action, but application code should enforce the transition rules.

04 PRACTICAL GUIDANCE

Checkpoints make interruptions manageable

A checkpoint is a saved representation of progress at a defined execution boundary. If a worker stops or a task waits for an external response, the orchestrator can reload the relevant checkpoint and determine what needs to happen next. For recovery after a process crash, the checkpoint must be stored somewhere that survives that crash; an in-memory dictionary is not sufficient.

Save important state transitions, particularly before waiting for human input and around external actions. Some workflow systems reconstruct state from a recorded sequence of events rather than restoring a complete snapshot. Temporal, for example, uses recorded workflow history to reconstruct progress on replay.[2] Both approaches require a clear contract for how work resumes.

Checkpoint frequency involves trade-offs. Very frequent writes can increase storage and processing overhead, while infrequent writes can leave more work to repeat following a failure. Choose boundaries based on the consequences of lost progress, not simply on how often the language model is called.

A paused task may resume under a new deployment of the agent. Record relevant state-schema and workflow versions, and test migrations or support older execution paths. An incompatible change should route the work item to a controlled recovery process instead of silently discarding essential state.

05 PRACTICAL GUIDANCE

The most dangerous failure is an uncertain outcome

A read-only request that times out can often be repeated. A request that changes a record is different. If an agent sends a refund request and the connection fails, it may not know whether the receiving service completed the operation.

Design such an action around a durable operation identifier. Save the intended operation before dispatching it, then pass the same identifier when retrying that same authorised action. If the receiving system supports idempotency, it can recognise a repeated request and avoid applying the effect again. AWS describes this pattern using caller-provided request identifiers.[3]

The distinction matters: a saved checkpoint cannot by itself guarantee that an external transaction happens only once. A crash can occur after the external service commits the change but before the agent records the result. Temporal's activity documentation similarly distinguishes workflow replay from the possibility that an external activity may execute again after a failure.[4]

After an uncertain outcome, query the receiving system using the operation identifier or another authoritative transaction reference. If the system confirms completion, record that outcome. If it guarantees a safe retry, retry under the same operation identity within the applicable retention and retry limits. If neither is possible, stop and request reconciliation. Do not invent a confirmation or send a fresh transaction simply because the previous one timed out.

Where an application controls its own database, a transactional outbox can persist a state change and an outgoing work request together. This reduces the risk of losing the request between those two operations, but message delivery may still be repeated. Consumers must therefore recognise duplicates and apply their own appropriate safeguards.

06 PRACTICAL GUIDANCE

Human approval must remain valid when the agent resumes

Human involvement is often what makes an enterprise agent acceptable. However, an approval screen is only useful if the subsequent execution respects precisely what the person authorised.

Bind approval to the specific operation and material parameters, such as the beneficiary, amount, currency and invoice version. The approval service should verify the approver's identity and authority, then store its decision outside the model's conversation. An approval for one action must not be reused for another.

When the task resumes, recheck applicable permissions, approval validity and relevant business data. If the invoice amount or beneficiary changes, invalidate the affected approval and request a new decision. If the underlying system reports that the invoice has already been paid, stop rather than executing the previously approved request.

Agent frameworks can help implement the pause-and-resume mechanism. LangGraph supports interrupts that persist graph progress and resume after external input; its documentation also warns about repeated execution of operations before the interruption.[5] The framework does not replace the organisation's own approval rules, access checks or escalation responsibilities.

07 PRACTICAL GUIDANCE

Where should an AI agent keep its state?

The choice of persistence architecture depends on task duration, concurrency, recovery requirements and the consequences of mistakes. There is no requirement to deploy a specialised database just because a process uses a language model.

Application memory: Suitable for brief, disposable interactions that can be restarted without business consequences. It is easy to implement but cannot provide crash-resistant progress on its own.

Durable relational storage: Useful when work items have clear stages, structured records, transactional updates and reporting needs. A database can enforce unique operation identifiers, version checks and controlled state changes.

Workflow orchestration: Useful for processes that span services, wait for approvals or need reliable scheduling and recovery. It adds integration and operational responsibilities but can reduce the amount of custom recovery logic that teams maintain.

Long-term memory stores: Useful for approved cross-session preferences or knowledge. A vector index may support retrieval by meaning, but similarity search is not a substitute for exact identification of transaction status or enforceable business state.

Combinations are possible. A procurement agent could use a workflow engine for execution, a relational database for its action records, a document system for supporting evidence and a search index for finding policy information. Each component should have a defined source-of-truth responsibility. Adding more storage systems without such boundaries makes reconciliation harder.

08 PRACTICAL GUIDANCE

What changes when several agents share the same task?

Suppose a procurement agent checks supplier eligibility while another reviews contract terms. Both may need to report findings to a coordinator. If both overwrite a shared state document at the same time, one result could disappear.

Assign agents clear responsibilities and define which fields they can update. Use an atomic version check, a controlled merge or serialised updates to prevent lost changes. Parallel branches should return separately identifiable results; the coordinator should verify which branches completed before moving the task forward.

Separate the right to recommend an action from the right to execute it. Two agents agreeing that a supplier is eligible does not constitute business approval. The application should still enforce eligibility rules and any required independent decision.

Long-running workflows also need protection against two workers acting on the same work item. A lease or claim can help coordinate ownership, but stale workers may still attempt a write. Version or fencing checks at the relevant resource and idempotent execution provide additional protection where supported. Use a single coordinated workflow when parallel agents offer little practical benefit.

09 PRACTICAL GUIDANCE

Keep the right information, not everything

State records and execution histories can accumulate confidential documents, customer identifiers, tool outputs and internal decisions. More retained information may make recovery easier, but it also increases storage, privacy and security responsibilities.

Keep secrets outside the state record and use scoped references to authorised resources. Encrypt sensitive persistence layers, enforce access at every read and update, and isolate records belonging to different users or organisations. Recheck permissions before loading historical context into the model.

Treat stored model outputs and retrieved documents as untrusted information. They may contain inaccurate statements or instructions that attempt to influence future actions. Validate structured proposals, distinguish their source from authoritative evidence and do not allow remembered text to change permissions.

Define how long checkpoints, audit records and optional memory should remain available. Their retention needs may differ. Where full content is not needed, retain the relevant reference, outcome and audit metadata under an approved retention policy. An operational record should explain what was done and why, without depending on private model reasoning.

10 PRACTICAL GUIDANCE

Test the failure cases before trusting the success cases

A successful demonstration tells you that an agent can follow one path under favourable conditions. Production testing must also establish whether it can recover without losing work or creating unintended actions.

Interrupt the application immediately before a tool call, after the receiving service completes it and before the local state records the result. Test duplicate messages, simultaneous updates, stale approvals, changed source data, permission revocation, corrupted checkpoints and a workflow resumed after a software upgrade. Confirm that unsuccessful or uncertain outcomes are visible to the people responsible for resolving them.

Measure verified completion rate, recovery success rate, time spent in each stage, duplicate-effect incidents, unresolved transaction outcomes and human interventions. Track the age of tasks awaiting a decision and the total cost per correctly completed work item. Include retries, storage, orchestration and review costs rather than measuring model usage alone.

Compare those measures against the existing process, including conventional automation. A deterministic workflow may already handle a fixed sequence reliably, with AI used only for interpreting unstructured inputs. Greater autonomy is worth considering only when the task genuinely benefits from flexible decisions and the additional controls are justified.

11 PRACTICAL GUIDANCE

Start with a task your business can supervise

Choose one bounded workflow, identify its authoritative records, define its permitted states and agree on the evidence required before any consequential action. Establish ownership of exceptions and a practical recovery route. Then decide which parts benefit from AI and which should remain deterministic.

If your organisation has an agent that performs well in demonstrations but struggles with interrupted workflows, repeated tool calls or pending approvals, review its state and recovery architecture before investing in a more capable model. Those issues may be architectural rather than linguistic.

The real measure of a dependable agent is not whether it can describe what it intends to do. It is whether the business can establish what has happened, what remains to be done and whether the next action is safe.

12 PRACTICAL GUIDANCE

References and further reading

[1] LangChain. LangGraph documentation: Persistence. Explains thread-specific checkpoints and cross-thread stores. Source: https://docs.langchain.com/oss/python/langgraph/persistence

[2] Temporal. Temporal Workflow documentation. Describes rebuilding execution state from recorded workflow history. Source: https://docs.temporal.io/workflows

[3] Amazon Web Services. The Amazon Builders' Library: Making retries safe with idempotent APIs. Source: https://aws.amazon.com/builders-library/making-retries-safe-with-idempotent-APIs/

[4] Temporal. Activity Definition documentation. Discusses activity retries and the importance of idempotent operations. Source: https://docs.temporal.io/activity-definition

[5] LangChain. LangGraph documentation: Interrupts. Describes persisted pauses, resumption and handling side effects around interrupts. Source: https://docs.langchain.com/oss/python/langgraph/interrupts

WORKED EXAMPLE / SAMPLE DATA

Apply the approach

Consider a supplier invoice workflow where a finance agent has completed its validation checks and prepared a payment request for human approval. The following example shows how a controlled state record could guide recovery after the approved submission experiences a network timeout. The stage names are design examples, not records of an actual transaction.

Approval pendingAWAITING_APPROVAL

The validated invoice and proposed payment are saved. No payment submission is permitted until an authorised decision is recorded.

Decision receivedAUTHORISED

The specific payment has been approved. Recheck the invoice version, outstanding balance and permissions before dispatch.

Submission outcome unclearSUBMISSION_PENDING

The operation identifier and attempted action are recorded. Reconcile with the payment service instead of blindly sending a new request.

Confirmed completionRECONCILED

An authoritative external record confirms the intended transaction. Record its reference and close the workflow without repeating the action.

IMPLEMENTATION CHECKLIST

Put the approach into practice

  1. 01Map a bounded business process, its valid state transitions, authoritative data sources and exception owners.
  2. 02Define the smallest durable state record that supports recovery, approval verification and audit evidence.
  3. 03Use stable operation identifiers and test duplicate protection for every consequential external action.
  4. 04Simulate crashes, timeouts, duplicate events, concurrent updates and approvals that become stale before execution.
  5. 05Compare correctly completed tasks, exception handling, turnaround and total cost with the existing process before scaling.
COMMON QUESTIONS

Frequently asked questions

Does every AI agent require persistent state?

No. An agent answering a disposable, read-only question may need only temporary context. Persistence becomes important when work must survive a restart, continue across sessions, wait for an approval or reliably track changes to external systems.

Can I use a vector database as the main agent state store?

A vector database can help find semantically relevant memories and documents. For operational state, use a mechanism that provides the exact identifiers, consistency, concurrency controls and durability required by your workflow. Retrieval relevance alone cannot establish the latest transaction or approval status.

How is checkpointing different from event sourcing?

Checkpointing saves a representation of progress at a particular boundary. Event sourcing records changes as events from which application state can be reconstructed. They can be combined, but each approach needs explicit recovery behaviour, version management and protection against duplicate external effects.

Can an AI agent safely resume after several days?

Yes, if its required state has been retained, the runtime supports resumption, and the application revalidates time-sensitive information, permissions and approvals. It should not assume that an old checkpoint reflects the current business situation.

How do I prevent an AI agent from repeating a payment or refund?

Keep the intended action and its stable identifier in durable storage, use an external service that supports appropriate duplicate protection where possible, and reconcile uncertain results against authoritative records. A checkpoint, a prompt instruction or a conversation log alone does not guarantee a single external effect.

CONTINUE EXPLORING

Related articles

Continue through the same expertise domain or explore another perspective.

Agentic AI
Puneett Bhatnagr · 14 min read

AI Agent Evaluation Framework: Can You Trust Your Agent to Act?

Learn how to evaluate AI agents beyond response accuracy, using verified task outcomes, tool-use checks, safety controls, reliability tests and business performance metrics before granting autonomy.

AI agent evaluation frameworkAgentic AIAgent reliabilityTool-use evaluationAI agent safetyAgent observability
Read article
Agentic AI
Puneett Bhatnagr · 13 min read

AI Agent Failure Recovery: What Happens When an Agent Gets Stuck?

An AI agent can fail halfway through a business process and leave real work unfinished. Learn how AI agent failure recovery uses checkpoints, safe retries, reconciliation and human oversight to protect customers, prevent duplicate actions and restore reliable operations.

AI Agent Failure RecoveryAgentic AIDurable executionIdempotencyWorkflow orchestrationHuman oversightAgent reliability
Read article
Agentic AI
Puneett Bhatnagr · 12 min read

AI Agent Identity and Access Control: Who Can Your AI Act For?

AI agents can access business systems and take actions. Learn how distinct identities, scoped permissions, delegated authority and human approvals keep enterprise AI agents accountable and secure.

AI agent identityAccess controlWorkload identityLeast privilegeDelegated authorisationAgentic AI security
Read article
Agentic AI
Puneett Bhatnagr · 14 min read

AI Agent Memory Design: What Should Your AI Actually Remember?

Design AI agents that resume work, remember relevant context and respect privacy. Learn how to manage memory, prevent stale decisions and evaluate business value.

AI Agent Memory DesignAgentic AILong-term memoryContext engineeringAgent state managementMemory securityAI agent evaluation
Read article
Agentic AI
Puneett Bhatnagr · 12 min read

AI Agent Tool Calling: How AI Moves from Answers to Actions

Learn how AI agent tool calling connects language models to business systems, automates tasks and keeps permissions, approvals, reliability and costs under control.

AI agent tool callingFunction callingAgentic AIEnterprise API integrationAI agent securityHuman approvalWorkflow automation
Read article
Agentic AI
Puneett Bhatnagr · 11 min read

Agent Planning and Task Decomposition: How AI Gets Work Done

Discover how AI agents turn complex goals into manageable tasks, coordinate tools, adapt to setbacks and deliver verifiable business outcomes within controlled limits.

Agent planningTask decompositionAgentic AIAI orchestrationTool callingHuman oversightAgent evaluation
Read article
Agentic AI
Puneett Bhatnagr · 12 min read

Human-in-the-Loop AI Agents: When Should People Step In?

AI agents can handle repetitive work without handing over every business decision. Learn how to design meaningful human approvals, manage exceptions and measure the value of supervised automation.

Agentic AIHuman-in-the-loop AI agentsHuman oversightAgent orchestrationTool callingApproval workflowsAI agent securityWorkflow automation
Read article
Agentic AI
Puneett Bhatnagr · 14 min read

LLM Model Routing Strategies: The Right Model for Each Task

Effective LLM routing matches model capability to business requirements. Explore evidence-backed strategies for balancing inference cost, response quality, latency, resilience and enterprise governance.

LLM model routingAI gatewaysModel cascadesInference costsLLM evaluationMulti-model architecture
Read article
Agentic AI
Puneett Bhatnagr · 13 min read

Model Context Protocol Architecture: How AI Connects to Your Business

Discover how Model Context Protocol (MCP) connects AI agents to enterprise data and tools, where reusable integrations create value, and how to control permissions, actions and operational risk.

Model Context ProtocolMCP architectureAgentic AIEnterprise AI integrationAI tool callingAgent security
Read article
Agentic AI
Puneett Bhatnagr · 11 min read

Single-Agent vs Multi-Agent Systems: When Is One AI Agent Enough?

Should your business use one AI agent or a team of specialists? Compare single-agent and multi-agent systems, their costs, risks and practical enterprise use cases.

Single-agent systemsMulti-agent systemsAgentic AIAI agent orchestrationEnterprise AI agentsAgent evaluationAI workflow automation
Read article
Agentic AI
Puneett Bhatnagr · 11 min read

Why AI Agents Become Slow and Expensive — and How to Fix It

AI agent cost and latency optimisation starts with the entire workflow. Learn to cut unnecessary calls, control retries and measure the cost of successful business outcomes.

AI agent cost and latency optimisationAgent orchestrationToken efficiencyAgent observabilityWorkflow automationAI unit economics
Read article
LET'S CONNECT

Let’s build something with AI.

I welcome conversations about enterprise AI, strategic advisory, executive leadership and research collaboration.

Use the inquiry form below
  • AI engineering and enterprise architecture
  • Responsible AI and model risk
  • Executive opportunities and consulting
  • Research and technical collaboration
AI collaborationA message connects enterprise AI strategy, AI engineering and responsible governance.AI COLLABORATIONConnectStrategyEngineeringGovernance

Send me an inquiry

Tell me about your AI challenge, leadership opportunity or research idea.

Please do not include confidential business data.

Enter the answer to confirm you are human.
Let’s connect

Explore the portfolio

Search the eight expertise pages, selected case studies and research records.