Items marked (preview) in this article are currently in public preview. This preview is provided without a service-level agreement, and we don’t recommend it for production workloads. Certain features might not be supported or might have constrained capabilities. For more information, see Supplemental Terms of Use for Microsoft Azure Previews.
Background execution and resilience
Background execution and resilience solve different problems. Background execution lets work continue without keeping the original HTTP connection open. Resilience lets a later process lifetime recover work after a restart, crash, out-of-memory termination, or redeployment.
For the Responses protocol, full crash recovery applies only to stored background responses when the server opts in to resilient background execution. Foreground responses remain tied to the client connection and aren’t reinvoked after a process interruption.
For the Invocations protocol, your application defines the request, response, and status contract. Use the AgentServer resilient task primitive to preserve execution, and expose the polling or streaming behavior that your clients need.
Resilient work model
A resilient unit of work has two identities:- A work identity names the logical job or multi-turn conversation.
- An input identity names one input or turn within that work.

Work shapes
Choose a work shape based on the lifetime and concurrency of the operation.
Calls that use the same one-shot work identity converge on the same logical operation instead of executing duplicate work. A multi-turn chain accepts turns sequentially. Steering is an optional mode that lets a newer turn queue behind the active turn and signal the current handler to finish early, so a conversation can redirect without starting a second concurrent handler.
Platform and application responsibilities
The runtime preserves execution metadata. Your application preserves domain progress.Preserve agent progress
Keep task metadata small. Use it as a checkpoint index, not as a checkpoint store. Good metadata values include:- An upstream framework session or checkpoint ID.
- The last completed workflow phase.
- An idempotency key for an external operation.
- A pointer to state in a database or blob store.
Any strategy can use a side-effect watermark. Persist the watermark before an operation that can’t be safely repeated, and clear it after the operation commits. A recovered handler checks the watermark before it issues the operation again.
Replay streamed output
Use a separate stream identity for each request or turn. Don’t reuse a multi-turn work identity as the stream identity because a completed stream closes while the conversation can continue with later turns. Replayable streams retain events and assign cursors that clients use when they reconnect. A persistent replay backing also lets a recovered producer find its last emitted cursor and continue with the next event. For a recovered Responses stream, a laterresponse.in_progress event is a snapshot reset. A client replaces its locally accumulated output with the snapshot in that event, discards partial output that isn’t in the snapshot, and then applies subsequent events. Output indexes identify slots in the current snapshot; they aren’t guaranteed to increase across recovery attempts.
Handle cancellation and shutdown
Cancellation and shutdown are cooperative. The runtime signals the handler, and the handler decides whether to return a partial result, finish normally, cancel, or defer unfinished work for recovery. Treat graceful shutdown differently from failure. If the handler can’t finish during the shutdown window, defer the work without writing a terminal state. A later process can then reclaim and reenter it. When steering is enabled, queued input can also signal the current turn to wind down. The conversation remains sequential: steering doesn’t create a fork or let two turns modify the same conversation concurrently.Design boundaries
Resilient tasks don’t provide deterministic replay, workflow orchestration, or bulk storage. They compose with these systems instead.- Use an agent framework checkpointer for graph state and human-in-the-loop suspension.
- Use a workflow engine for fan-out, fan-in, durable timers, or child workflows.
- Use application storage for large inputs, generated artifacts, and external state.
- Use idempotency support from downstream services whenever it’s available.