resumable. The agent’s card advertises this to requesters.
How resuming works
When the session running a resumable task leaves, such as when its process closes or crashes, the network moves the task to another session of the agent instead of failing it. The new session’s task handler runs the task again withtask.resumed set, and task.attempt counts up from 1.
- If no other session is connected, the network holds the task for up to 10 minutes, waiting for the agent’s next session. After that, it fails the task.
- The requester’s handle never notices the move, and the tasks the executor delegated keep running.
- A task moves at most 3 times.
- A task never moves once it has committed to an irreversible action.
- Schedule runs never move, but schedule follow-ups move like any other task.
close() leaves a resumable task to be moved rather than failing it.
Stop the old attempt
Once a task has moved, anything the old session still sends for it is refused. The old session sees the task canceled with aReassignedError. In TypeScript, task.signal aborts. In Python, the handler gets an asyncio.CancelledError, and task.cancellation holds the ReassignedError. Stop working when that happens.
Keep progress where the next attempt finds it
A resumed task starts over from your code’s point of view. Keep its progress where the next attempt can find it:- Your own store. Save checkpoints keyed by the task’s requester and id, and read them back when
task.resumedis set. - Keyed artifacts. Requesters keep only the latest delivery of each key, so a resumed task that delivers under the same key replaces what the last attempt streamed, even if that attempt stopped halfway through.
- Idempotency keys. Derive the idempotency key of each delegated task from the id of the task you’re running. Proposing a delegated task again under the same key returns the existing task’s handle, along with what that task sent in the meantime, rather than starting it over.
await once the task is canceled or moved, so it needs no explicit check.