fix(dotnet): recover from dropped session idle events#2016
Open
hydraxman wants to merge 4 commits into
Open
Conversation
hydraxman
force-pushed
the
fix/dotnet-session-idle-reliability
branch
from
July 17, 2026 02:27
11e23c4 to
57c96dd
Compare
hydraxman
marked this pull request as ready for review
July 22, 2026 14:23
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a resilient .NET SendAndWaitAsync fallback when ephemeral idle notifications are dropped.
Changes:
- Uses runtime task-drain and activity RPCs to confirm completion.
- Adds FIFO event-dispatch barriers and stale-activity protection.
- Adds unit and E2E regression coverage.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
dotnet/src/Session.cs |
Implements runtime completion fallback and dispatch barriers. |
dotnet/test/Unit/ClientSessionLifetimeTests.cs |
Tests dropped-idle recovery and activity races. |
dotnet/test/E2E/SendAndWaitReliabilityE2ETests.cs |
Adds end-to-end reliability coverage. |
test/snapshots/send_and_wait_reliability/should_complete_when_live_sessionidle_is_dropped.yaml |
Provides the replay fixture. |
hydraxman
force-pushed
the
fix/dotnet-session-idle-reliability
branch
from
July 23, 2026 23:10
eb53c32 to
de29350
Compare
Comment on lines
+594
to
+595
| var queued = _eventChannel.Writer.TryWrite(new EventItem(sessionEvent)); | ||
| ObjectDisposedException.ThrowIf(!queued, this); |
Comment on lines
+556
to
+559
| DispatchEvent(session, new AssistantTurnEndEvent | ||
| { | ||
| Data = new AssistantTurnEndData { TurnId = "queued-during-final-barrier" } | ||
| }); |
Comment on lines
+601
to
+603
| var dispatchGate = typeof(CopilotSession).GetField("_eventDispatchGate", BindingFlags.Instance | BindingFlags.NonPublic) | ||
| ?.GetValue(session) | ||
| ?? throw new InvalidOperationException("Event dispatch synchronization gate was not found."); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
SendAndWaitAsyncrecover when the ephemeralsession.idlenotification is droppedReproduction
assistant.turn_endsession.idlestill completes the callTests
$HOME/.dotnet/dotnet test test/GitHub.Copilot.SDK.Test.csproj -f net8.0 --no-restore --filter 'FullyQualifiedName~SendAndWaitAsync_Completes_When_SessionIdle_Notification_Is_Dropped|FullyQualifiedName~SendAndWaitAsync_Preserves_Event_Completion_When_Legacy_Runtime_Lacks_Fallback_Rpcs|FullyQualifiedName~SendAndWaitAsync_DroppedIdle_Fallback_Flushes_Preceding_Event_Handlers|FullyQualifiedName~SendAndWaitAsync_DroppedIdle_Fallback_Rechecks_Activity_After_Final_Barrier'— 4 passed$HOME/.dotnet/dotnet test test/GitHub.Copilot.SDK.Test.csproj -f net8.0 --no-restore— 690 passed, 3 skipped$HOME/.dotnet/dotnet build src/GitHub.Copilot.SDK.csproj --no-restore— 0 warnings, 0 errors$HOME/.dotnet/dotnet format --verify-no-changes --no-restoregit diff --checkFixes #2008