Repository navigation
.NET: Fix flaky MultiStepOperationTimeout unit test - #10231
Conversation
Wait for the timeout token to be cancelled instead of a fixed delay, which could finish before the timer callback on loaded runners. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 85e502db-0565-4d9c-94bb-b86f57fc296c
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for this test-only timeout synchronization change.
No open issues 🎉
What changed in this PR
This test-only change addresses intermittent CI failures in the .NET shared-timeout test by waiting for token cancellation rather than assuming a fixed delay is sufficient. Production code is unchanged.
Changes:
- Replace the fixed 200 ms delay with a cancellation-driven wait.
- Bound the wait with a 30-second safety delay and assert that cancellation completed first.
- Retain assertions for the completed step’s result and the subsequent timeout exception.
| File | Description |
|---|---|
dotnet/tests/Microsoft.Agents.AI.UnitTests/Harness/MultiStepOperationTimeoutTests.cs |
Synchronizes the timeout assertion with token cancellation to avoid the fixed-delay race. |
Review effort: Balanced
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (1 commit(s)): a80fcab03890
Model: gpt-5.6-sol
Overview
This test-only change replaces a fixed delay with a bounded wait for the timeout token's actual cancellation, directly addressing the timer-callback race described in the PR. Cancellation registration handles already-cancelled tokens, RunContinuationsAsynchronously avoids callback-thread continuation hazards, and the final assertion still exercises the production RunStep timeout path. No Critical, High, or Medium defect was established.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
Code coverage overviewLanguages: C# C# / code-coverage/dotnet
View coverage of the 5 most impacted files.
ℹ️ Calculations represent line coverage. Results may change as calculations are updated. |
Motivation & Context
MultiStepOperationTimeoutTests.RunStep_CompletedStepDoesNotResetTimeoutAsyncfails intermittently in CI and has been kicking unrelated PRs (e.g. #10175) out of the merge queue. Example failure ondotnet-test (net472, windows-latest, Release): https://github.com/microsoft/agent-framework/actions/runs/42819308461Description & Review Guide
Task.Delay(200)and then expectedRunStepto throw. On a loaded runner (notably .NET Framework), theCancelAftertimer callback may not have run yet when the delay completes, so the token is not cancelled and noTimeoutExceptionis thrown. The test now waits for the timeout token's cancellation itself (bounded by a 30 s safety delay) before asserting.Related Issue
N/A - trivial change: test-only fix for a timing race in an existing unit test.
AI Assistance
AI assistance details: failure investigation, test fix, and this PR description.
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.