fix(dotnet): recover from dropped session idle events#2016
Open
hydraxman wants to merge 2 commits into
Open
Conversation
hydraxman
force-pushed
the
fix/dotnet-session-idle-reliability
branch
from
July 17, 2026 02:27
11e23c4 to
57c96dd
Compare
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. |
Comment on lines
+440
to
+445
| catch (RemoteRpcException ex) when (ex.ErrorCode == RemoteRpcException.MethodNotFoundErrorCode) | ||
| { | ||
| // Older runtimes may not expose activity/task-drain RPCs. Preserve the | ||
| // existing event-only behavior and let session.idle or the timeout win. | ||
| LogRuntimeCompletionFallbackUnavailable(ex, SessionId); | ||
| } |
Comment on lines
+57
to
+60
| var handlersField = typeof(CopilotSession).GetField( | ||
| "_eventHandlers", | ||
| BindingFlags.Instance | BindingFlags.NonPublic) | ||
| ?? throw new InvalidOperationException("CopilotSession._eventHandlers 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_endTests
dotnet test test/GitHub.Copilot.SDK.Test.csproj -f net8.0 --no-restore --filter 'FullyQualifiedName~SendAndWaitAsync_Completes_When_SessionIdle_Notification_Is_Dropped|FullyQualifiedName~SendAndWaitAsync_DroppedIdle_Fallback_Flushes_Preceding_Event_Handlers|FullyQualifiedName~SendAndWaitAsync_DroppedIdle_Fallback_Rechecks_Activity_After_Final_Barrier|FullyQualifiedName~SendAndWaitReliabilityE2ETests'dotnet test test/GitHub.Copilot.SDK.Test.csproj -f net8.0 --no-restore— 676 passed, 3 skippedCOPILOT_SDK_DEFAULT_CONNECTION=inprocess dotnet test test/GitHub.Copilot.SDK.Test.csproj -f net8.0 --no-restore --filter 'FullyQualifiedName~SendAndWaitReliabilityE2ETests'dotnet build src/GitHub.Copilot.SDK.csproj --no-restore— 0 warnings, 0 errorsdotnet format --verify-no-changes --no-restoreFixes #2008