Skip to content

dotnet: Deflake session event capture - #2745

Open
devm33 wants to merge 1 commit into
mainfrom
devm33/deflake-dotnet-session-events-enumeration
Open

devm33 wants to merge 1 commit into
mainfrom
devm33/deflake-dotnet-session-events-enumeration

Conversation

@devm33

@devm33 devm33 commented Sep 22, 2026

Copy link
Copy Markdown
Member

Problem

The runtime repository's SDK compatibility run 35719029303 failed SessionE2ETests.Should_Receive_Session_Events on Alpine with:

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

The test records startup events in a mutable List<SessionEvent> from an asynchronous event callback, then enumerates that list after observing session.start. Later event delivery can mutate the list during the assertion. The test is worthwhile because it verifies that events emitted during session creation are not dropped.

Changes

Use ConcurrentQueue<SessionEvent> for the startup-event capture. This preserves the assertion while making concurrent callback writes and test enumeration safe.

Product impact

No SDK product behavior changes. This only removes a race from the .NET E2E test.

Validation

  • Reproduced by github/copilot-agent-runtime run 35719029303, Alpine .NET in-process CAPI leg.
  • git diff --check
  • Local .NET execution unavailable in the current environment; CI validation is required.
Validation Run
Exact-head .NET validation 1-10 (2390cf6681e3e24b289d6ee72fa729b664c944bb) Pending

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: c2ef3b8a-d96c-4821-b346-694f49854981
@devm33
devm33 requested a review from a team as a code owner September 22, 2026 11:57
Copilot AI balanced review requested due to automatic review settings September 22, 2026 11:57
@devm33 devm33 added post-to-slack Post PR to reviewers Slack channel deep-review Requested detailed code review skip-changelog No user-facing changelog entry required labels Sep 22, 2026

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 change correctly eliminates the identified enumeration race.

Review effort: Balanced
Findings: None

What changed in this PR

Deflakes the .NET session-event E2E test by making asynchronous event capture thread-safe.

Changes:

  • Replaces List<SessionEvent> with ConcurrentQueue<SessionEvent>.
  • Uses Enqueue for concurrent callback writes.
File Description
dotnet/​test/​E2E/​SessionE2ETests.cs Prevents concurrent modification during startup-event assertions.

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

@github-actions

Copy link
Copy Markdown
Contributor

SDK Consistency Review

This PR (dotnet: Deflake session event capture) only touches dotnet/test/E2E/SessionE2ETests.cs, replacing a non-thread-safe List<SessionEvent> with ConcurrentQueue<SessionEvent> (and .Add.Enqueue) to fix a flaky test where events captured from a background OnEvent callback race with the main thread's assertions.

Assessment: No cross-SDK consistency concerns.

  • This is an internal test-reliability fix, not a public SDK API change.
  • No new feature, method, or behavior is being added/changed in the .NET client itself — only test-harness code.
  • Other language SDKs' equivalent E2E tests are unaffected and don't need changes.

No action needed for other SDKs.

Generated by SDK Consistency Review Agent for #2745 · copilot · sonnet50 · 13.7 AIC · ⌖ 11.4 AIC · ⊞ 7.8K ·

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

deep-review Requested detailed code review post-to-slack Post PR to reviewers Slack channel skip-changelog No user-facing changelog entry required

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants