Skip to content

.NET Built-in Retry Policies for Agent Calls #2687

@lukemurraynz

Description

@lukemurraynz

Current Behavior: No built-in retry logic. Transient failures (network timeouts, rate limiting) require manual retry implementation.

Problem: AI APIs are inherently unreliable (rate limits, throttling, transient errors). Every production application needs retry logic.

Recommended Changes:

Integrate with Microsoft.Extensions.Http.Resilience patterns
Add RetryPolicy to AgentRunOptions
Support exponential backoff and circuit breaker patterns
Provide sensible defaults for common scenarios
Example Desired API:

// Built-in retry configuration
var agent = chatClient.CreateAIAgent(
    name: "ReliableAgent",
    instructions: "...",
    options: new AgentOptions
    {
        RetryPolicy = RetryPolicy.Exponential(
            maxRetries: 3,
            baseDelay: TimeSpan.FromSeconds(1))
    });

// Or per-invocation override
var result = await agent.RunAsync(
    prompt,
    options: new AgentRunOptions
    {
        RetryPolicy = RetryPolicy.NoRetry  // Disable for this call
    });

Metadata

Metadata

Assignees

Labels

.NETagentsIssues related to single agents

Type

No type
No fields configured for issues without a type.

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions