Skip to main content
Some agent workflows must stop and wait for a person - to approve an action, answer a question, or provide missing input - and then continue. A long-running hosted agent can pause indefinitely for that reply without holding a request open or losing its place, because a multi-turn chain persists between turns.
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:
  1. The agent does work until it needs a human decision.
  2. It returns a turn that asks for the decision (the chain suspends).
  3. A person replies; your app starts a new turn on the same task_id.
  4. The handler resumes and continues with the human’s answer.
Because the chain is durable, the wait can be arbitrarily long - minutes, hours, or days - and survives container restarts.

Implement the approval turn

Drive it from your application:
Keep only small references in ctx.metadata (an expense ID, a step number). Store the full request, history, or generated artifacts in your own storage or a framework checkpoint. See Manage state for long-running agents.

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. Set resilient_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.