How to resume agent runs without duplicate actions
A run restarts after a crash, and the email goes out twice. An unfinished step can run again from its beginning. Check what your framework reruns, separate external actions into their own steps, send an idempotency key with every write that supports one, and test with a controlled crash.
Find where the run starts again
A retry attempts failed work again; a resume continues a saved run. A checkpoint records the run's state so it can continue later. A side effect changes something outside that state, such as sending email. An idempotency key identifies one intended operation so the receiving service can recognize repeated attempts.
In LangGraph, retries restart nodes, the graph's steps, and discard failed attempts' state updates. Crash resumes and interrupts, pauses for outside input, also restart nodes from their beginning. External writes are not undone; application code must make them safe to repeat.
- LangGraph Functional API: resume restarts the entrypoint, the function that starts the run, and restores completed task results. Tasks group work; unfinished tasks can run again.
- Temporal: an Activity, a function performing one action, can finish and run again if its process crashes before reporting completion.
- DBOS: retries a step if its workflow (the sequence of steps) failed while executing it; completed, checkpointed steps never run again.
- Restate: on failure, retries the function and replays its journal, the record of each step and its result, skipping completed steps.
Among the reports of failed resumes, one team on the LangChain forum said its runs can take up to 20 minutes to finish. Two runs that take longer than 20 to 30 minutes were cancelled during worker shutdowns and resumed repeatedly. Repeated resumes exceeded the default limit of three attempts, causing failure.
A LangGraph Cloud user reported calls over about three minutes dispatched again while originals still ran; both completed. The issue remains open; the reporter later said the team left LangGraph Cloud and solved duplicates with its own job system. One person in a CrewAI thread reported duplicate outbound emails on retry.
Check what survives a restart
Use a persistent checkpointer such as PostgresSaver: LangGraph checkpoints held only in memory are lost on restart.
In LangGraph, sync mode saves checkpoints before the next step; async writes during it, with a small risk of an unwritten checkpoint if the process crashes. Exit mode saves on completion, error or interruption; crashes during execution cannot be recovered.
In every mode, sync included, a crash before the first saved checkpoint leaves no checkpoint evidence that the run started. To distinguish accepted runs from ones never received, record them in your own store before starting them.
Keep pauses separate from side effects
One LangChain forum user saw logs before an interrupt repeat on every resume. The accepted answer called rerunning intended and suggested an earlier node; the reporter chose to split the node.
LangGraph says effects before an interrupt must be idempotent, meaning repetition causes no additional change, and recommends placing them after the interrupt or in separate nodes.
One team on the LangChain forum reported unsaved data written in a node before an interrupt. A reply explained that interrupted nodes' writes are discarded; the team now saves its own event log.
In the OpenAI Agents SDK, approval permits a tool call but cannot ensure a single execution: resuming an older approved snapshot can repeat a call whose result was never saved.
Send an idempotency key with every write
Save the key before the side effect runs. LangGraph says to derive it from durable state, saved to survive a crash, such as an order ID. Without such an identifier, generate it in its own node before the effect and use sync durability so the intervening checkpoint is durable.
The OpenAI Agents SDK recommends a stable key and unchanged parameters per intended action, with atomic duplicate prevention at the destination. Atomic means checking the key and applying the write are one indivisible operation, so two attempts cannot both take effect. Respect the destination's key retention period and retry rules.
For API v1, once execution begins, Stripe saves the response, errors included, returns it for the same key and rejects changed parameters. Keys can be removed after at least 24 hours; reusing a removed key creates a new request.
Persist keys across restarts and reuse them on every attempt. Stripe's error guidance treats a 500 server response as indeterminate; resolve the original outcome before using a new key.
If destination idempotency is unavailable or no longer valid, retry only after the destination confirms that no earlier attempt performed the action or can still perform it. A missing lookup result cannot prove retrying is safe: reads can lag, and an earlier request can still complete.
If uncertainty remains, record the outcome as unknown and avoid automatic replay.
A 2026 study tested models retrying writes against six simulated services after injected faults. In its counterfactual setup, every write accepted an idempotency key; agents attached keys in 98% of episodes, and the duplicate rate fell from 28% to 4%. These rates describe that simulated setup.
Remaining duplicates involved an initial missing key or a changed retry key. The study tested nine models and three production agent harnesses, command line agents and frameworks wrapping a model. Code and data are promised upon publication; the author discloses AI assistance in drafting parts of the code and text.
Match time limits to real work
Temporal Activities retry by default without an attempt limit. In most cases, Temporal recommends the Schedule-To-Close Timeout to limit the total duration of retries, rather than a maximum number of attempts, and marking errors requiring code or input changes as nonretryable. A heartbeat reports progress; Temporal recommends that Activities finish within a few minutes or send heartbeats.
If you run LangGraph's Agent Server on your own Kubernetes cluster, set terminationGracePeriodSeconds at least as long as BG_JOB_SHUTDOWN_GRACE_PERIOD_SECS, the time a stopping worker gives runs in progress. Otherwise, Kubernetes kills the process before those runs finish.
A reply on the thread says BG_JOB_SHUTDOWN_GRACE_PERIOD_SECS has a maximum of 3600 seconds, and a later reply says 3600 seconds is the hard cap on LangGraph Cloud.
Repeat the crash test
In a test environment, stop the process during a slow call, restart it and resume the run. Repeat after the side effect completes but before its result is saved.
Record step starts, idempotency keys, side effects and saved results. Check for one effect per intended write, reused results from completed steps, and an unknown status when the destination's outcome cannot be established.
Keep these cases with your document answer tests, including tests for agents that search in several steps. Rerun them after changes to frameworks, storage, tools or retry policies to decide which actions can recover automatically.
Where Rachis fits
Running agents over documents means connecting document processing, retrieval and workflow execution. Connect your app to the Rachis API. Rachis runs the entire pipeline and returns the results, without you wiring together the frameworks, queues and recovery code.
Join the waitlist: one email when there is something to try.