Pausing and Resuming Agent Runs
In this article
- Say what a waiting run must save so that a restarted worker can carry on, including its expiry time and the status the user sees.
- Decide the one final state and the one status text when approve, expire, cancel and duplicate events arrive in any order.
- Write the check that accepts an event only with the run's id, the current resume token and a state that allows it.
- Map the same ideas onto LangGraph's interrupt() and Command(resume=...).
- Terms defined here: pause and resume, run status, resume token.
Overview
An agent asks a manager to approve a refund and then waits. The wait can last hours. During it your service is redeployed, the deadline passes, the customer cancels, or the approval click is delivered twice. Each of those is an event, and they do not arrive in a tidy order. Which one wins, and what does the customer see?
Take a made-up support agent's run that refunds 49.00 EUR on order 1042 after a manager approves it. Refunds above 40.00 EUR wait for approval, and the wait ends 24 h after the request. You will see what the waiting run saves, which events each state accepts, and how one small function turns any order of events into one ending and one honest status line.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- A pause is a saved record
- After a restart
- What each state accepts
- One function decides
- Four orders, one ending
- Common mistakes
- In production
- Sources
- Check yourself, 13 questions