Skip to main content
This reference lists the AgentServer SDK surface for building long-running, resilient hosted agents: the resilient task primitives, the resilient Responses options, and the streaming registry. For the concepts behind these APIs, see Resilience for long-running hosted agents. For task-oriented walkthroughs, see the how-to guides.
Long-running agents are in preview. The APIs on this page are from the azure-ai-agentserver packages and are subject to change.

Packages

The APIs on this page require at least the following package versions. The Python packages are generally available; the .NET packages are in preview—install them with --prerelease.
Use the latest available version. The versions listed are the minimums that include the resilient task, resilient Responses, and streaming-registry APIs described here.

Resilient tasks

The task primitives make a unit of work crash-resilient. Declaring a task automatically enables the startup recovery scan.

Declare a task

Run a task

TaskContext

The handler receives a TaskContext describing the current attempt. entry_mode / EntryMode values:

TaskRun

The handle returned by start / StartAsync.

Retry policy

Retries apply to handler failures, not to crash recovery. Crash recovery re-enters the same attempt and doesn’t consume retry budget.
Delay formula: min(initial_delay * backoff_coefficient ** attempt, max_delay).

Task status and exceptions

TaskStatus (C#) / status values: Pending, InProgress, Suspended, Completed.

Force-enable recovery

Declaring a task auto-enables the recovery scan. Force-enable it when tasks are registered lazily after host startup.

Resilient Responses options

Set on ResponsesServerOptions when constructing the host. Both flags default to off.

Recovery-aware ResponseContext

Available on the response handler’s context when resilience is enabled.

Streaming registry

Pick one backing at startup, then look streams up by a per-turn id.
Registry operations: await streams.get_or_create(id), await streams.delete(id). Pass cursor_fn to enable subscribe(after=...) and last_cursor().
Streaming exceptions: EventStreamClosedError/EventStreamClosedException, EventStreamNotFoundError/EventStreamNotFoundException, and the base EventStreamError/EventStreamException.