Skip to content

[External] Copilot SDK: CopilotClient should auto-reconnect to persistent server #536

@PureWeen

Description

@PureWeen

Problem

When the TCP connection to the persistent copilot CLI server drops, CopilotClient does not attempt to reconnect. The entire client must be disposed and recreated, which orphans all active session event handlers and requires re-resuming every session.

Impact on PolyPilot

  • Client recreation is expensive: 68 sessions must be re-resumed (~3 seconds)
  • Sessions that were mid-turn lose their event streams (bystander damage)
  • The user sees a Blazor surface reset as the entire session list re-renders
  • Force-complete logic is needed for bystander sessions — complex workaround code

Desired SDK Behavior

Since CopilotClient connects to a persistent server (not an embedded process), it should transparently reconnect when the TCP connection drops:

  1. Detect connection loss internally
  2. Re-establish the TCP connection to the same CliUrl / port
  3. Re-attach session event handlers without requiring session.resume from the app
  4. Emit an informational event (e.g., ConnectionRestoredEvent) so the app can update UI

Current Workaround

PolyPilot disposes the old CopilotClient, creates a new one, and calls session.resume for all ~68 sessions. Sessions that were processing are force-completed with whatever response was flushed so far. The triggering session's prompt is retried on the new client.

SDK Reference

GitHub.Copilot.SDK v0.2.1 — CopilotClient persistent mode (CliUrl + AutoStart=false)

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