Skip to content

[External] Copilot SDK: No OnDisconnected/OnConnectionLost callback on CopilotClient #535

@PureWeen

Description

@PureWeen

Problem

When the TCP connection between CopilotClient and the copilot CLI server drops, the SDK provides no notification. PolyPilot only discovers the dead connection when SendAsync throws a connection error — at which point the user has already typed a message and hit send.

Impact on PolyPilot

  • All in-flight sessions lose their event streams when the client is recreated
  • Sessions that were mid-turn must be force-completed with partial/empty responses
  • The user sees a brief Blazor surface reset as all sessions re-resume
  • Observed today (2026-04-07): reconnect at 16:50 UTC caused 2 bystander sessions (Mobile-Fixes, maui-CIQuestions) to lose their in-flight responses

Desired SDK Behavior

CopilotClient should expose an OnDisconnected or OnConnectionLost event/callback. This would allow PolyPilot to:

  1. Detect dead connections proactively (before the user tries to send)
  2. Show a connection status indicator in the UI
  3. Auto-reconnect in the background without disrupting the user

Current Workaround

PolyPilot catches connection errors in SendAsync, recreates the CopilotClient, re-resumes all sibling sessions, and force-completes any sessions that were mid-turn with dead event streams. This works but causes response loss for bystander sessions.

SDK Reference

GitHub.Copilot.SDK v0.2.1 — CopilotClient has no disconnect/connection-health API surface.

Metadata

Metadata

Assignees

No one assigned

    Labels

    externalUpstream bug or dependency issue

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions