Long-running agents are in preview. APIs and package versions are subject to change.
How pause-and-resume works
A@multi_turn_task chain doesn’t end when a turn returns - it moves to the suspended state and stays alive under one task_id. The next input on the same task_id reenters the same handler with ctx.entry_mode == "resumed". That is the natural shape for a human-in-the-loop pause:
- The agent does work until it needs a human decision.
- It returns a turn that asks for the decision (the chain suspends).
- A person replies; your app starts a new turn on the same
task_id. - The handler resumes and continues with the human’s answer.
Implement the approval turn
Use a framework interrupt with Responses
If you build on an agent framework (for example, LangGraph or Microsoft Agent Framework) over a background response, use the framework’s own interrupt and approval mechanism. Keep the response resilient so the pause survives a restart. Setresilient_background=True and persist the framework’s checkpoint at the interrupt point. On resume, rebuild from that checkpoint. See Recover long-running work after a crash.
Clean up a finished chain
You delete a suspended chain only when you delete it explicitly. The system automatically cleans up one-shot@task records when they complete.