Thanks to visit codestin.com
Credit goes to github.com

Skip to content

.NET: Fix abort recovery test event subscription race - #2635

Merged
stephentoub merged 1 commit into
mainfrom
stephentoub-sdk-capi-test-repairs
Sep 12, 2026
Merged

.NET: Fix abort recovery test event subscription race#2635
stephentoub merged 1 commit into
mainfrom
stephentoub-sdk-capi-test-repairs

Conversation

@stephentoub

Copy link
Copy Markdown
Collaborator

Summary

Fix the recovery wait in SessionE2ETests.Should_Abort_A_Session. The test previously awaited SendAsync before subscribing through GetFinalAssistantMessageAsync. A fast recovery turn can deliver session.idle before that subscription; because idle is ephemeral, the helper cannot recover it from GetEventsAsync and times out even when the assistant message is present.

Use the existing SendAndWaitAsync API to subscribe before sending. Preserve the tool-start/send/abort/aborted-idle ordering, the original 120-second timeout, and both recovery assertions. Explicitly dispose the session.

Add deterministic fake-RPC coverage that exercises the same abort/recovery scenario as the E2E test. Event fences force tool-start, abort idle, and recovery messages to be processed before RPC replies; recovery idle is covered both before and after the send reply. Fake event history excludes idle.

This is a test-only change. The shared image-replay fix is separate and is not included here.

Validation

  • Before the fix: the forced early-idle regression failed with Timeout waiting for assistant message; the other case passed.
  • After the fix: both regression cases and 18 adjacent send-and-wait cases passed on net8.0 (20 total).
  • Focused command: dotnet test .\dotnet\test\GitHub.Copilot.SDK.Test.csproj -f net8.0 --no-restore -p:CopilotSkipCliDownload=true -m:1 --filter "FullyQualifiedName~Abort_Recovery_Observes_Early_Events|FullyQualifiedName~SendAndWaitAsync_MessageSource_Completes_On_Idle".
  • Opus 5 self-review found no high-confidence issues.

The lost-idle ordering is deterministically reproduced. It is consistent with the abort-test timeout seen in github/copilot-agent-runtime#19858, but that specific CI occurrence cannot be conclusively attributed without its recovery event trace. No runtime build or full E2E rerun was performed for this change.

Generated by Copilot

Copilot AI balanced review requested due to automatic review settings September 12, 2026 01:24
@stephentoub
stephentoub requested a review from a team as a code owner September 12, 2026 01:24

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The focused test-only changes preserve existing behavior while reliably covering the reported race.

Review tier: Balanced
Findings: None

What changed in this PR

Fixes a .NET abort-recovery E2E race by subscribing before sending the recovery prompt.

Changes:

  • Uses SendAndWaitAsync and explicitly disposes the session.
  • Adds deterministic fake-RPC coverage for early and late recovery-idle ordering.
  • Models idle events as ephemeral in fake history.
File Description
dotnet/​test/​E2E/​SessionE2ETests.cs Removes the recovery subscription race.
dotnet/​test/​Unit/​ClientSessionLifetimeTests.cs Adds deterministic regression coverage and fake event history.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

This comment has been minimized.

Subscribe before sending the recovery prompt so an ephemeral session.idle cannot be lost. Exercise the shared abort scenario through the fake RPC server with events delivered before replies, retaining the original ordering and timeout budget.

Co-authored-by: Copilot App <[email protected]>
@stephentoub
stephentoub force-pushed the stephentoub-sdk-capi-test-repairs branch from d764b81 to daedce3 Compare September 12, 2026 02:28
@github-actions

Copy link
Copy Markdown
Contributor

SDK Consistency Review — PR #2635

Scope of changes: Only 2 files were modified, both under dotnet/test/ (E2E/SessionE2ETests.cs and Unit/ClientSessionLifetimeTests.cs). No production SDK client code (dotnet/src/, nodejs/src/, python/copilot/, go/, java/sdk/src/main/java/, rust/src/) was touched by this PR.

Findings:

  • This PR refactors an existing .NET E2E test (Should_Abort_A_Session) into a reusable helper (AssertAbortAndRecoveryAsync) and adds a corresponding unit test (Abort_Recovery_Observes_Early_Events) plus fake-server plumbing (BeforeResponseAsync/AfterResponseAsync, session event recording) to validate that early events (e.g. an assistant message arriving before session.idle) are correctly observed during abort/recovery.
  • The change uses session.SendAndWaitAsync(...), which is existing public .NET SDK API (not introduced by this PR) — no new client API surface is added.
  • Since no SDK client/public API code changed, there is no cross-language feature-parity gap introduced by this PR. This is a test-only reliability/coverage improvement scoped to the .NET SDK's test suite.

Conclusion: No cross-SDK consistency issues found. No action needed for other language SDKs.

Generated by SDK Consistency Review Agent for #2635 · copilot · sonnet50 · 15.4 AIC · ⌖ 12.1 AIC · ⊞ 8.3K ·

@stephentoub
stephentoub added this pull request to the merge queue Sep 12, 2026
Merged via the queue into main with commit f45c46f Sep 12, 2026
55 checks passed
@stephentoub
stephentoub deleted the stephentoub-sdk-capi-test-repairs branch September 12, 2026 07:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants