A demo agent runs for ninety seconds, calls three tools, and prints a tidy answer. A production agent runs for ninety minutes, sometimes ninety hours, across dozens of tool calls, one process restart, two policy checks, and a human approval that takes a day to arrive. That gap between the demo and the deployment is exactly where most agentic projects die.1

The reason is rarely the model. Frontier models reason well enough to draft a plan and call the right tools. What breaks is the machinery around the model: the loop holds its progress in memory, and the first time a container restarts, a network call times out, or a reviewer says "not yet," the whole run forgets where it was and starts over. An agent that reconciles a quarter of invoices over three days cannot afford to restart at step one every time the worker pod is evicted. A chat agent can forget; an agent touching your ledger cannot.1

This article is about the layer that makes long-running agents safe to trust: durable execution. The idea is simple to state and hard to bolt on late. Treat the workflow as a state machine whose progress is written down after every step, make every tool call it makes safe to repeat, and give a human an explicit gate before the high-risk actions. Get those three right and an agent can run for days, crash at step forty-seven, and resume at forty-eight instead of re-sending forty-seven emails. Skip them and you are one restart away from a double charge and a customer who notices.1

A long-running agent is a different animal from a demo

The first trap is calling a long-running workflow an "agent" and leaving it at that, as if the label settled the design. It does not. A long-running agent is defined less by a clock than by its execution lifecycle: it is any agentic workflow that cannot finish inside a single synchronous request-response window because it must wait on an external system, a human approval, or multi-step reasoning that spans minutes, hours, or days.2 A financial close that pulls from three ERPs, an e-discovery job that crawls a million documents over a weekend, a contract that iterates across several stakeholder reviews. All of these must hold context, survive interruption, and pick up exactly where they left off. A naive implementation, a Python script with a long loop and in-memory state, fails the moment the container restarts or a dependent API times out.2

Stretch the run time and four problems surface at once: state, failure, cost, and trust. State is the first wall, because the workflow's working memory has to live somewhere that survives a restart, not in a process that can be killed at any moment. Failure is the second, because most agent frameworks treat each LLM call as fire-and-forget with no memory of what already happened. Cost is the third and the sneakiest, because every loop iteration is an LLM call, agents consume roughly four times the tokens of standard chat by one 2026 estimate, and a task you estimated at ten model calls can balloon to eighty once the agent hits an unexpected state and starts self-correcting. Trust is the fourth, and the one the enterprise now worries about most, because an agent that runs unattended for hours is exactly the system a compliance officer will ask who was watching.1

Crash recovery: a naive agent restarts at step one and re-sends every side effect, while a durable agent replays its event log and resumes at step forty-eight
Crash recovery: a naive agent restarts at step one and re-sends every side effect, while a durable agent replays its event log and resumes at step forty-eight

The cleanest way to see the stakes is to watch what happens when the process dies at step forty-seven of a hundred. A naive agent restarts at step one, re-charging the card, re-sending the email, re-running every mutation it already completed. A durable agent replays an immutable event history and resumes at step forty-eight. That single difference, resume where you left off instead of redoing everything, is why frameworks from LangGraph to Pydantic AI to the OpenAI Agents SDK have all made durable execution a first-class feature. In Temporal's framing it is no longer optional infrastructure but a baseline requirement.1

The state machine that refuses to forget

Durable execution has a concrete shape, and it is worth drawing because the shape is what protects you. A production agent is governed by an explicit state machine rather than an unbounded loop. Execution moves through distinct, verifiable states: the task is queued with its inputs validated, a worker claims it and runs the current step, the worker commits the step's outcome and writes a checkpoint, the task can drop into waiting while it holds for an external signal or a human approval, and on a crash it moves to resuming, replays what already happened, and continues from the last good step.3

The orchestration engine is the spine of this design. Its only job is to guarantee that a workflow which began survives crashes, restarts, deploys, and multi-day waits without losing its place. It does this by recording every step as an immutable event log; on recovery it replays that log to rebuild in-memory state, then continues from the last completed step rather than the beginning. Temporal describes workflows that automatically hold state over long periods of time, even years, so you do not hand-roll the state machine yourself.1

You have two implementation routes, and they are not mutually exclusive. Graph-state checkpointing, the LangGraph style, captures state at each node and persists it to SQLite, Postgres, or S3. It fits graph-shaped reasoning where you want thread-local and cross-session memory with minimal infrastructure.4 Durable workflow engines, Temporal and Restate and the durable queues, add retries, timers, signals, and event history with stronger semantics. They shine when the agent must coordinate payments, approvals, notifications, or multi-hour background jobs. Match the machinery to the blast radius rather than adopting the heaviest option by default. A short, read-only agent with no side effects can run on graph checkpointing alone.1

Durable task state machine lifecycle: queued, running, checkpointed after each step, waiting for a human or event, resuming by replay, and terminating in completed, failed, or aborted
Durable task state machine lifecycle: queued, running, checkpointed after each step, waiting for a human or event, resuming by replay, and terminating in completed, failed, or aborted

The checkpoint rule that decides everything is deceptively short: checkpoint after every step that has an external side effect, or that you cannot cheaply recompute. That is the whole discipline in one line. Anything in between, the snapshot-everything-versus-pause-at-safe-points tuning, is a trade between recovery granularity and write overhead. Complete snapshots save the entire agent state, context, and intermediate data, so they recover anywhere but cost more to store. Clean breakpoints only permit pauses at predefined safe points, which are cheaper but can only resume at sanctioned boundaries. Pick breakpoints when actions are expensive to interrupt; pick snapshots when you need fine-grained recovery.1

One design rule keeps replay honest, and teams violate it all the time: the planner must stay stateless with respect to durability. The orchestrator owns the durable state; the planner is a pure function from current state to next action. Given the same event history, it produces the same plan, so recovery does not silently change behavior. When teams let their planners hold hidden mutable state, replay diverges, the recovered run makes a different decision than the original one would have, and the durability guarantee quietly evaporates.1

Idempotency is the price of replay

Replay is only a feature if doing a step twice does no harm. That requirement has a name, idempotency, and it is non-negotiable for any agent whose steps touch the real world. Without it, replay turns a recovery mechanism into a double-billing machine: the crash happened mid-request, the retry re-sends the same API call, and the customer gets charged twice.1

The fix is mechanical but it has to be built into every mutating tool call. Each side-effecting action carries a deterministic idempotency key, typically derived from the task id and the step number, something like idem_task882_step4. The external tool or an API gateway in front of it checks that key in a deduplication store before executing. If the key has already been processed, the gateway returns the cached output from the earlier call instead of running the mutation again. The replay engine, meanwhile, skips side effects it already committed. The result is that a task can retry in-flight work as often as it needs to without ever duplicating a charge, an email, or a state change.3

Idempotency key deduplication: a replayed tool call carries a stable key that the gateway matches in a dedup store and returns the cached result instead of double-executing the mutation
Idempotency key deduplication: a replayed tool call carries a stable key that the gateway matches in a dedup store and returns the cached result instead of double-executing the mutation

This is where the distributed-systems habits that predate LLMs become the agent's best friend. The same rules that stop a payment worker from double-settling a transaction apply to an agent that thinks it is settling a transaction. Message queues with exactly-once delivery help, but do not rely on them alone; the agent itself must be defensive, because the agent controls the retry loop and the queue does not. Treat "update status to processed" as an atomic move and quarantine "email sent to the user" behind a deduplication window. Design every step to be safely retryable from the start, because retrofitting idempotency after customers report lost tasks is far more expensive than building it in.2

Put a human at the gate, not in the loop

Durable execution gives you the ability to pause a workflow cleanly, and that ability is what turns a blunt "human in the loop" into something defensible: human at the gate. This is a separate layer from the one that decides an agent's output is even trustworthy before a human sees it, which we wrote about in valid JSON is not correct data; durability is about the workflow surviving the wait and the restart, output reliability is about the value the model emits being right. The 2026 pattern is risk-based approval routing rather than blanket human review of everything. Classify each action into a risk tier. Let low-risk flows auto-execute and log them. Sample-audit medium-risk ones. Require a synchronous human approval before any high-risk action proceeds, and park the workflow in a durable waiting state until that approval arrives or a timeout aborts it.1

The distinction between guardrails and governance matters here. Guardrails are deterministic, fast checks applied to every action: is this SQL safe, is this recipient on an allow-list, does the output leak a secret, does it match the schema. They run unconditionally and cheaply. Governance is the risk-tiered routing that decides whether a human must look before an action runs at all. Guardrails keep the autonomous loop inside its lane on every step; governance decides which steps are too consequential to let the loop take on its own.1

Risk-tiered approval routing: an agent action is scored, then auto-executed if low risk, sample-audited if medium risk, or held at a synchronous human approval gate with a challenge-and-response checklist if high risk
Risk-tiered approval routing: an agent action is scored, then auto-executed if low risk, sample-audited if medium risk, or held at a synchronous human approval gate with a challenge-and-response checklist if high risk

When a human does have to approve, make the approval mean something. The strongest guidance is a challenge-and-response checklist: the approver positively acknowledges the intent, the data lineage, the permissions chain, the expected blast radius, and the rollback plan before the action runs. They are not rubber-stamping; they are confirming they understand what is about to happen. Two independent second opinions on critical actions, whether a second reviewer or a counter-model sanity check that is not the model that proposed the action, close the last gap. Every decision goes to an audit log, and the audit log is only useful if the durable state made the full path reconstructable after the fact.1

Two escape hatches keep a governed agent from becoming an unlimited one. A hard step counter or budget ceiling forces an aborted terminal state when a run exceeds its bounds, and an approval timeout does the same when a human goes silent. Without those, "resume forever" becomes "spend forever," which is why the same guidance pairs durability with cost control: a hard step counter, a per-session token or dollar budget that triggers an abort, and action deduplication against recent steps. Industry analysis reports that trio prevents roughly ninety percent of runaway scenarios.1

Adroit on the Ground: what our own pipeline taught us

We run a delivery chain at Adroit that is, underneath the product branding, a long-running governed workflow, and it has taught us the same lesson the reference architectures do. Work does not live in a single process; it lives in a durable board where each task moves through explicit states, a task a crash interrupted is resumed from its saved state rather than started over, and nothing is treated as done until a mechanical verification gate passes and a human reviewer signs off. That is durable execution in miniature, and it is why we can ship many work items a day without a runaway loop or a duplicated delivery slipping through.

The transferable point for a client is not that we happen to run this way. It is that the pattern is load-bearing wherever an agent touches consequential work. The organizations that get long-running agents to production treat the workflow as the product and the model as one bounded reasoning step inside it. They check progress after every side effect, they make every tool call idempotent, they put a human gate in front of high-risk actions, and they cap the loop so a self-correcting agent cannot spend its way past the budget. The demo that impresses a stakeholder and the deployment that survives a quarter are built on the same model and entirely different machinery.12

Where durability earns its keep, and where it does not

Durable execution is not free, and the honest engineering question is when it pays for itself. The decision rule that keeps coming up across the 2026 guidance is a pair of questions. Can you draw the full set of execution paths at design time, including the exception branches? Then you mostly have a workflow problem, and a deterministic engine gives you the same input producing the same output with a full audit trail. Does the execution path genuinely depend on open-ended reasoning over unstructured inputs that you cannot pre-specify? Then you have an agent problem, and durability is what keeps that agent from losing its place.5

The middle cases are where the strongest teams land: deterministic orchestration as the skeleton and the LLM as a reasoning organ at specific, bounded decision points. A workflow engine drives the overall process. Individual activities within it make LLM calls for the parts that genuinely need natural-language reasoning, each call wrapped in a defined input contract, an output schema, and a retry policy. The workflow code is deterministic and crash-recoverable. The LLM calls are non-deterministic but bounded, they happen inside a defined activity and the engine controls the path.5

This hybrid has a subtle advantage that is easy to miss. When a durable workflow replays after a crash, it does not re-invoke the LLM; it replays the recorded result from the original call. The non-deterministic reasoning happens once, and the orchestration layer remembers it. That means a recovered run is reproducible for an audit in a way a raw agent loop never is, because the same input produces the same output with a complete trail of what the model decided and why. For a regulated client in finance, insurance, or healthcare, that reproducibility is not a convenience. It is the difference between "the agent decided to do it this way" and an execution record a compliance officer can point to.5

The signals that a task has hidden workflow structure are easy to spot once you look. If the agent follows the same path eighty percent of the time, that path is the workflow backbone and the LLM should only reason at the decision points that vary. If failures cluster around specific transitions, that is usually a place the agent needs to maintain state across steps, which orchestration handles natively. If the task has human approval or wait states, agents handle those poorly and a durable engine has explicit primitives for pausing pending an external signal. And if cost scales linearly with volume, the run has predictable per-execution costs, which is the signature of structure worth exploiting rather than autonomy worth buying.5

None of this is an argument against agents. It is an argument for precision about what the LLM is good at, which is reasoning, versus what orchestration is good at, which is the execution guarantee. Where multi-agent systems are concerned, the same discipline applies: a durable single workflow that coordinates several agents still needs the state machine, and the structural failure modes of naive agent stacks that we mapped in multi-agent orchestration are often just this missing durability surfacing as tangled retries. Agents genuinely win when the value comes from adaptive behavior no fixed flowchart would capture: a research assistant deciding which sources to query based on what it finds, a negotiator changing tactics from a counterpart's reply. They lose, expensively, when they are pointed at a structured process with enumerable exceptions and asked to improvise their way through it, because the failure rates for autonomous systems applied to structured work are brutal, one study of over sixteen hundred production traces put them between forty-one and eighty-seven percent.5

Start your next long-running agent by asking what must survive. If the answer includes a side effect, a human approval, or a wait that outlasts a process, you have a durable-execution problem, and you should build the state machine, the idempotency keys, and the approval gate before you tune a single prompt. The demo will still run in ninety seconds. The production agent will run for ninety hours, crash at step forty-seven, and resume at forty-eight, and nobody will have been double-charged on the way.

Sources

  1. Long-Running Governed AI Agents: Architecture 2026 2 3 4 5 6 7 8 9 10 11 12 13 14 15

  2. AI Agents in Production: Long-Running Workflows, PADISO 2 3 4

  3. Building Reliable Long-Running Agent Tasks, Digital Elliptical 2

  4. Graph-Based Agentic AI with LangGraph: Workflow Pathways for Long-Running Stateful Business Processes, arXiv

  5. When Workflow Engines Beat LLM Agents: A Decision Framework, Tianpan 2 3 4 5