Skip to content

Fix Copilot client cold-start and Kerberos proxy handling - #332375

Merged
Don Jayamanne (DonJayamanne) merged 2 commits into
release/1.135from
don/merge-fixes-1.135
Aug 24, 2026
Merged

Fix Copilot client cold-start and Kerberos proxy handling#332375
Don Jayamanne (DonJayamanne) merged 2 commits into
release/1.135from
don/merge-fixes-1.135

Conversation

@DonJayamanne

Copy link
Copy Markdown
Contributor

Enhance the Copilot client to self-heal from cold-start aborts due to configuration changes and normalize the handling of empty Kerberos proxy SPNs to prevent unnecessary restarts. Fixes #332305.

…332256)

* agent host: self-heal Copilot client cold-start config-changed abort

When a startup-config value changes while the Copilot SDK client is
starting, `_ensureClient` aborts the now-stale start and throws
`CopilotClientStartupConfigChangedError`. Because the next start uses the
current config, that abort is transient — but it was surfaced to session
restore, producing sticky failures such as "could not describe … yet" /
"Couldn't open session".

`_ensureClient` now transparently re-acquires the client once with the
current config. The acquire-and-retry sequence is shared across all
concurrent callers via `_ensureClientHealing`, so the retry budget is
global (bounded by `MAX_STARTUP_CONFIG_RETRIES`) rather than per caller,
and per-attempt coalescing in `_ensureClientOnce` is unchanged. No caller
observes the transient abort.

Related to microsoft/vscode-internalbacklog#8895

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

* agent host: address review on the _ensureClient self-heal

Two findings from the automated review:

- Clear `_ensureClientHealing` from inside the async sequence's `finally`
  rather than a trailing `.finally()` on a separate chain. The external
  chain ran one microtask after awaiting callers resumed, so a caller that
  resumed on success and immediately re-entered `_ensureClient` (e.g. after
  `_stopClient()`) could be handed the fulfilled handle for an already-
  stopped client, bypassing the `_clientStopping`/`_client` guards. Clearing
  in-sequence guarantees the handle is gone before the promise settles for
  any awaiter. Confirmed the ordering fix in isolation.

- Strengthen the global-budget test so it actually discriminates. The
  previous version had both callers coalesce before attempt 1, so a
  per-caller budget would pass it too. The late joiner now arrives while
  attempt 2 is in flight (mid-retry) and is shown unable to drive a third
  start. Verified by mutation: removing the shared coalescing makes the test
  fail with startCallCount 3.

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

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…art (#332306)

* agent host: normalize empty Kerberos proxy SPN to avoid spurious restart

An unset `http.proxyKerberosServicePrincipal` reaches the agent host two ways:
absent (`undefined`) when the Copilot client first spawns, then as an empty
string once the workbench mirrors its config (the transform coerces an unset
value to `''` so that clearing a previously-set SPN still propagates under the
host's merge reducer). `_refreshProxy` compared the two raw, so `'' !== undefined`
was mistaken for a real proxy change and restarted the Copilot client. When that
restart lands during a session restore it cancels the in-flight resume with a
CancellationError that is not recovered, leaving an empty Chat Panel after
restarting VS Code.

Read the SPN through a single helper that normalizes `''` to `undefined` at both
the applied-baseline (`_applyProxyEnv`) and effective-value (`_refreshProxy`)
sites, so an absent-vs-empty transition is no longer seen as a change. Clearing a
genuinely-set SPN still restarts. Also name the actual trigger in the restart log
instead of the misleading `(none) -> (none)`.

Fixes #332305

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

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings August 24, 2026 16:58
@DonJayamanne
Don Jayamanne (DonJayamanne) marked this pull request as ready for review August 24, 2026 17:00

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.

Pull request overview

Improves Copilot Agent Host startup reliability and avoids redundant runtime restarts.

Changes:

  • Retries once after startup configuration changes.
  • Coalesces concurrent recovery attempts.
  • Normalizes empty Kerberos proxy SPNs and expands coverage.
Show a summary per file
File Description
copilotAgent.ts Adds bounded startup recovery and SPN normalization.
copilotAgent.test.ts Tests recovery, concurrency, and Kerberos scenarios.

Review details

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

  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

@DonJayamanne
Don Jayamanne (DonJayamanne) merged commit c418d19 into release/1.135 Aug 24, 2026
28 checks passed
@DonJayamanne
Don Jayamanne (DonJayamanne) deleted the don/merge-fixes-1.135 branch August 24, 2026 17:51
@vs-code-engineering vs-code-engineering Bot added this to the 1.135.0 milestone Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants