.NET: Add timeout for wait-for-first-completion - #7911
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a configurable timeout to prevent background-agent waits from blocking indefinitely.
Changes:
- Adds a five-minute default
WaitTimeout. - Preserves running tasks after timeout.
- Adds validation and timeout behavior tests.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
BackgroundAgentsProviderOptions.cs |
Defines the timeout option and default. |
BackgroundAgentsProvider.cs |
Applies timeout validation and bounded waiting. |
BackgroundAgentsProviderTests.cs |
Tests defaults, validation, metadata, and timeout behavior. |
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: Findings reported
Scope: full PR (2 commit(s)): 7f414cedbe1c, 69816930c557
Model: gpt-5.6-sol
Overview
The PR adds a host-configurable timeout that returns control without cancelling child tasks, and its completion-race recheck plus retained-state tests protect the intended retry behavior. The model-facing schema correctly keeps timeout configuration host-only. One contract gap remains: the public option accepts positive durations that the underlying timer rejects when the wait tool is invoked.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
1 verified finding remained after source verification (1 medium) across 1 file. Details are attached to the affected lines below.
Affected areas: dotnet/src/Microsoft.Agents.AI/Harness/BackgroundAgents/BackgroundAgentsProvider.cs
Motivation & Context
Without a timeout,
background_agents_wait_for_first_completioncan suspend the calling agent's run indefinitely when a child task never completes. Bounding the wait returns control to the model so it can inspect status, retry the wait, or take another action while the child tasks continue running.Description & Review Guide
BackgroundAgentsProviderOptions.WaitTimeoutwith a five-minute default, bounds the wait tool using that timeout, and returns a normal retry-oriented message when the timeout expires. Adds tests for defaults, validation, model-facing tool metadata, completion, timeout behavior, and retained task state.TimeSpanconfiguration surface.Related Issue
Fixes #7454
This is the .NET implementation. #7908 and #7904 address the Python implementation.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.