Question-led guide · reliability

How can a long-running agent resume safely after hours or days?

A resume contract for durable agents that separates checkpointed state, external effects, versions, leases, approvals, revalidation, and recovery.

Direct answer

Resume a long-running agent from a versioned workflow checkpoint, never from conversational tone. Persist task state, completed and pending effects, idempotency keys, artifacts, model/tool/policy versions, leases, deadlines, and observation time. On wake, revalidate current resources and authority, reconcile uncertain effects, rebuild context from typed state, and continue only from an explicit transition whose preconditions still hold.

Scope

Use this pattern for agents that pause for humans, rate limits, scheduled time, asynchronous jobs, external events, or work spanning multiple model sessions. It focuses on durable execution state. Commit-time authorization expiry and duplicate side effects have separate guides because they require additional controls.

Why it happens

A paused conversation looks like state: it contains the plan, tool results, and a final sentence such as “waiting for approval.” Hours later, however, the world has changed. A deployment moved, data was edited, a token expired, another worker completed the action, or code now interprets the transcript differently.

Model context is also lossy. Compaction may omit an exception, and regenerating a summary can change meaning. Safe resumption requires a system of record that names completed transitions and external effects independently of prose.

Diagnosis

Crash the workflow at four points: before an external call, after the call but before recording its result, after recording success, and while waiting for approval. Restart with a different worker and, if supported, a newer code version.

For each run, ask:

  • Can the engine identify the exact last committed transition?
  • Can it distinguish not attempted, in flight, committed, failed, and outcome unknown?
  • Are artifacts immutable or version-addressed?
  • Can it detect that target state, policy, identity, approval, or deadline changed?
  • Does replay repeat a side effect?
  • Can an operator explain and override the recovery decision?

Solution

Persist a checkpoint after deterministic state transitions and before exposing the next action. Record external calls in an effect ledger with idempotency keys and target references. When a crash leaves the outcome unknown, query the target by that key or reconcile observed state; never assume failure and resend blindly.

On wake, verify checkpoint integrity and code compatibility. Refresh current resource state, policy, identity, approval, deadlines, and dependency versions. Rebuild model context from the typed snapshot and authoritative artifacts. The next transition should evaluate explicit preconditions and create a new decision record.

Migration deserves a first-class path. If old histories cannot replay under new code, route them through a reviewed migration or complete them with the old worker version.

Artifact

The resume contract contains:

Contract area Required fields
Workflow identity Task, tenant, workflow type/version, run, owner, and creation time
Checkpoint Sequence, integrity hash, last transition, state schema, and code version
Artifacts Stable IDs, versions, provenance, and access policy
Effects Proposed/in-flight/committed/failed/unknown state, target, and idempotency key
Wait condition Event, deadline, lease, approver, and cancellation rule
Authority snapshot Actor, scopes, policy, approval, target, and expiry
Wake checks Current state, authority, deadlines, dependencies, and conflict detection
Next transition Preconditions, allowed tools, budgets, and rollback/compensation
Handoff Owner and packet when automatic reconciliation fails

Common mistakes

  • Treating a chat summary as the workflow database.
  • Replaying nondeterministic code without version control.
  • Retrying an external action whose previous outcome is unknown.
  • Resuming with the identity and approval captured days earlier.
  • Migrating state schemas without testing historical checkpoints and effect records.

Evidence

  1. Durable workflow execution relies on persisted event history and replayable workflow logic, with constraints on nondeterministic behavior.

    Temporal's workflow-execution documentation describes durable executions, event histories, replay, task processing, and workflow lifecycle concepts.

    Primary source · official-doc · checked Aug 26, 2026

    Limit: Temporal is one implementation; using it does not automatically make external effects idempotent or reauthorize an expired action.

  2. Long-running agents benefit from explicit progress artifacts, incremental work, and a harness that can orient a later session.

    Anthropic's engineering article describes harness patterns for work across multiple context windows, including progress files and incremental task structure.

    Primary source · official-doc · checked Aug 26, 2026

    Limit: The examples concern coding-agent experiments and do not prove safe production effect coordination.

  3. Resume should be a reconciliation protocol over durable state and effects, not a request for the model to remember what it meant.

    The agent-resume contract below defines what must be persisted and rechecked before the next transition.

    Signal Studio author framework · reviewed Aug 26, 2026

    Limit: Exact checkpoint granularity and recovery behavior depend on workflow engine, external systems, and business consequences.

Limitations

A resume contract cannot make every external service transactional. Checkpoints can be corrupt or stale, effects may have unknown outcomes, and code or policy migrations can invalidate replay. High-impact recovery needs tested compensations and human ownership.

FAQ

Can I store the full transcript and send it back to the model?
The transcript can be an audit artifact, but it is a weak execution checkpoint. Reconstruct the next context from typed state, authoritative artifacts, pending decisions, and current policy.
Does a durable workflow engine prevent duplicate external actions?
It can persist orchestration state and replay decisions, but external calls still need idempotency keys, effect records, and reconciliation for unknown outcomes.

Continue within Context engineering, memory, and state, or use one of these adjacent diagnostics:

Editorial QA: automated native-English, structure, source-presence, and link checks completed . This record is not an independent expert endorsement. Review boundary.