microsoft / microsoft/agent-framework

.NET Multi-Agent Orchestration Timeout and Cancellation Handling

Open
#2,685 4 comments 0 reactions 1 assignee View on GitHub

@alliscode is already working on this.

Since Dec 9, 2025.

.NET workflows
Dominant language
Python
Stars
13.6k
Forks
2.3k
Avg merge
2d 45m
Merged PRs (30d)
358

Description

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)
});
```

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.