Fix Copilot client cold-start and Kerberos proxy handling - #332375
Merged
Don Jayamanne (DonJayamanne) merged 2 commits intoAug 24, 2026
Conversation
…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 started reviewing on behalf of
Don Jayamanne (DonJayamanne)
August 24, 2026 16:59
View session
Don Jayamanne (DonJayamanne)
marked this pull request as ready for review
August 24, 2026 17:00
Don Jayamanne (DonJayamanne)
enabled auto-merge (squash)
August 24, 2026 17:01
Contributor
There was a problem hiding this comment.
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
Dmitriy Vasyura (dmitrivMS)
approved these changes
Aug 24, 2026
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.
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.