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

Skip to content

Fix appended system-message test event subscription race - #2636

Draft
devm33 wants to merge 1 commit into
mainfrom
fix-appended-system-message-wait
Draft

Fix appended system-message test event subscription race#2636
devm33 wants to merge 1 commit into
mainfrom
fix-appended-system-message-wait

Conversation

@devm33

@devm33 devm33 commented Sep 12, 2026

Copy link
Copy Markdown
Member

Summary

Fix the response wait in SessionE2ETests.Should_Create_A_Session_With_Appended_SystemMessage_Config. It subscribed through GetFinalAssistantMessageAsync only after awaiting SendAsync. A completed turn can deliver its ephemeral session.idle first; durable history then contains the assistant message but cannot supply the missing idle notification.

Use SendAndWaitAsync to subscribe before sending. Preserve the original 120-second E2E timeout, prompt, response assertions (GitHub and Have a nice day!), and captured system-message assertions. No SDK or runtime production code changes.

The deterministic regression drives the E2E test's actual response-wait scenario. It reuses the fake RPC server added in #2635, delivers assistant/idle events, and drains a later event before replying to session.send. It also verifies that durable history contains the assistant but no idle event.

Failure evidence

Observed during validation of github/copilot-agent-runtime#20258: first-attempt CAPI run 34677727987, job 103512036461, runtime head 4a585d08bf, SDK commit a6f2e56acb5e04af56241146668fe71291304266. The appended-system-message case timed out at TestHelper.cs:77/85, called from SessionE2ETests.cs:58; that backend finished with 892 passes, one failure, and four skips.

The original CI event trace was not uploaded, so its exact interleaving is unknown. The following controlled reproductions establish a live test race with the same failure, not retrospective proof of that CI interleaving.

Validation

  • Original replay-backed E2E, with a temporary probe holding SendAsync's return until actual idle delivery: failed with Timeout waiting for assistant message after the unchanged 120-second wait. The probe observed one durable assistant message and zero durable idle events.
  • Same runtime, capture, and probe with the acknowledged send: passed all original response and system-message assertions. The temporary production probe was removed and removal verified against git.
  • Retained fake-RPC regression with original shared-scenario ordering: failed with the same helper timeout. With the fix, the complete ClientSessionLifetimeTests and SessionE2ETests files passed: 164 tests on net8.0, no skips.
  • dotnet format test/GitHub.Copilot.SDK.Test.csproj --no-restore --verify-no-changes passed.

Local replay validation used the freshly built runtime at dependency-integration commit 44613db704; toolchain was .NET SDK 10.0.401 with the required .NET 8 runtime. No fixture changes are included.

Ten independent .NET SDK Tests workflow runs were dispatched on exact head 34f8036f87aa4e186804066cea00d4f529b78190, each verified as attempt 1: 34680184778, 34680186084, 34680187444, 34680188695, 34680189919, 34680190926, 34680191987, 34680193191, 34680194253, 34680195312. These are new workflow runs, not reruns of failed checks.

The population is incomplete: six workflows succeeded; four hit the macOS default/CAPI shard 1 job limit. GitHub labels runs 34680184778, 34680187444, 34680188695, and 34680189919 as cancelled, but each affected job's annotation explicitly reports the 20-minute execution limit. They are not manual cancellations or passes, and a timeout alone does not establish an infrastructure failure.

The first timed-out job (103517319544) completed setup but never recorded completion of the test step. Its job log returns 404, no diagnostic artifact was retained, and the full workflow archive omits that shard. No individual test can yet be attributed from that evidence.

Both the repaired appended-system-message E2E and its early-idle regression are verified 10/10 passing in the Ubuntu/default/CAPI/full jobs, using original runner-native result lines, exact first-attempt metadata, and hashed logs. No test failures were found in those selected logs; incidental cache-reservation messages were kept separate. These target-level passes do not clear the four macOS job timeouts or establish ten successful whole workflows. No failed jobs have been rerun.

Exact-head Copilot review 5185720603 recommended approval with no findings and no inline threads. This is automated review clearance, not a formal human approval or completion of the ten-success CI requirement.

Generated by Copilot

Subscribe before sending and reuse the existing RPC event fence to reproduce early ephemeral idle delivery in the E2E test's actual response wait.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: faf9a106-bb3d-40e7-bf7b-9fce99d945a7

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 correctly eliminate the event-subscription race and preserve existing assertions.

Review tier: Balanced
Findings: None

What changed in this PR

Fixes an E2E race by subscribing for completion events before sending the prompt.

Changes:

  • Replaces split send/wait calls with SendAndWaitAsync.
  • Adds deterministic regression coverage for early idle delivery.
File Description
dotnet/​test/​E2E/​SessionE2ETests.cs Uses race-safe response waiting.
dotnet/​test/​Unit/​ClientSessionLifetimeTests.cs Tests assistant/idle events arriving before the send reply.

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

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.

2 participants