Skip to content

.NET Multi-Agent Orchestration Timeout and Cancellation Handling #2685

@lukemurraynz

Description

@lukemurraynz

Current Behavior: When orchestrating multiple agents sequentially or in parallel, there's no built-in timeout handling. Long-running agent calls (20-40s each) can cascade into multiple-minute delays without proper circuit breakers.

Problem: Production systems need timeout protection:

Individual agent calls may hang due to API issues
Cascading timeouts in multi-agent scenarios aren't well-handled
CancellationToken propagation works but lacks timeout metadata
Evidence from Codebase:

// src/services/MultiAgentOrchestrator.cs:65-72
// Had to implement custom timeout configuration
var clientOptions = new Azure.AI.OpenAI.AzureOpenAIClientOptions
{
    NetworkTimeout = TimeSpan.FromSeconds(60)  // Manual workaround
};

// Each agent call takes 20-40s with tools
// No framework-level timeout orchestration

Recommended Changes:

Add Timeout property to AgentRunOptions
Throw AgentTimeoutException with partial results when timeout occurs
Provide built-in timeout policies for common scenarios
Support graceful degradation when sub-agents timeout
Example Desired API:

// Per-invocation timeout
var result = await agent.RunAsync(
    prompt,
    options: new AgentRunOptions 
    { 
        Timeout = TimeSpan.FromSeconds(30),
        TimeoutBehavior = TimeoutBehavior.ReturnPartial  // or ThrowException
    });

// Agent builder timeout policy
var agent = chatClient.CreateAIAgent(
    name: "SlowAgent",
    instructions: "...",
    options: new AgentOptions
    {
        DefaultTimeout = TimeSpan.FromSeconds(45)
    });

Metadata

Metadata

Assignees

Labels

.NETv1.0Features being tracked for the version 1.0 GAworkflowsRelated to Workflows in agent-framework

Type

No type

Projects

Status

No status

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions