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
- Python
- C#
Run a task
- Python
- C#
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.- Python
- C#
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.- Python
- C#
Resilient Responses options
Set onResponsesServerOptions 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.- Python
- C#
Registry operations:
await streams.get_or_create(id), await streams.delete(id). Pass cursor_fn to enable subscribe(after=...) and last_cursor().EventStreamClosedError/EventStreamClosedException, EventStreamNotFoundError/EventStreamNotFoundException, and the base EventStreamError/EventStreamException.