Skip to content

Support CAPI WebSocket connections#4069

Merged
chrmarti merged 1 commit intomainfrom
chrmarti/prime-dragon
Feb 27, 2026
Merged

Support CAPI WebSocket connections#4069
chrmarti merged 1 commit intomainfrom
chrmarti/prime-dragon

Conversation

@chrmarti
Copy link
Collaborator

Cherry-picking #4068

Copilot AI review requested due to automatic review settings February 27, 2026 16:37
@chrmarti chrmarti enabled auto-merge February 27, 2026 16:37
@chrmarti chrmarti self-assigned this Feb 27, 2026
@vs-code-engineering vs-code-engineering bot added this to the February 2026 milestone Feb 27, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an optional WebSocket transport for CAPI Responses API requests (cherry-pick of #4068) to enable per-turn, per-conversation connection reuse across tool-calling rounds in the VS Code Copilot Chat extension.

Changes:

  • Introduces IChatWebSocketManager and a Node implementation that creates/reuses a WebSocket per (conversationId, turnId) (gated by a team-internal experiment flag).
  • Plumbs conversationId/turnId through request options and tool-calling flow so the fetcher can choose WebSocket vs HTTP.
  • Adds telemetry dimensioning for request transport (http vs websocket) and refactors Responses API completion telemetry sending into a helper.

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/platform/networking/node/chatWebSocketManager.ts New WebSocket connection manager + connection/request handle implementation.
src/platform/networking/common/networking.ts Adds conversationId/turnId to chat request options for request-scoped state.
src/platform/endpoint/node/responsesApi.ts Extracts completion-output telemetry sending into sendCompletionOutputTelemetry.
src/platform/configuration/common/configurationService.ts Adds team-internal flag chat.advanced.responsesApi.webSocket.enabled.
src/lib/node/chatLibMain.ts Registers NullChatWebSocketManager for chat-lib Node context.
src/extension/test/vscode-node/services.ts Registers NullChatWebSocketManager for extension tests.
src/extension/test/node/services.ts Registers NullChatWebSocketManager for unit tests.
src/extension/prompt/node/test/chatMLFetcherRetry.spec.ts Updates ChatMLFetcherImpl construction with a WebSocket manager dependency.
src/extension/prompt/node/test/chatMLFetcherResponseApiTelemetry.spec.ts Updates ChatMLFetcherImpl construction with a WebSocket manager dependency.
src/extension/prompt/node/defaultIntentRequestHandler.ts Injects WebSocket manager, closes per-turn connection in finally, passes ids into request creation.
src/extension/prompt/node/chatMLFetcherTelemetry.ts Adds transport field to success/cancel/error telemetry payloads + schema.
src/extension/prompt/node/chatMLFetcher.ts Implements WebSocket fetch path for Responses API and emits transport-aware telemetry.
src/extension/intents/node/toolCallingLoop.ts Ensures turnId is included in fetch options for tool-calling loops.
src/extension/intents/node/testIntent/testIntent.tsx Wires new constructor parameter for WebSocket manager in test intent handler.
src/extension/extension/vscode-node/services.ts Registers real ChatWebSocketManager in the VS Code Node extension host.
src/extension/byok/vscode-node/geminiNativeProvider.ts Adds transport field to GDPR telemetry schema.
src/extension/byok/vscode-node/anthropicProvider.ts Adds transport field to GDPR telemetry schema.
Comments suppressed due to low confidence (1)

src/platform/networking/node/chatWebSocketManager.ts:309

  • On cancellation you reject the active request but leave the WebSocket open. If the server keeps streaming for the cancelled response, those late events can leak into the next request (since _activeRequest will be replaced) and also waste bandwidth/server resources. Consider closing the connection (or sending an explicit cancel message) when the request is cancelled.
		const cancelDisposable = token.onCancellationRequested(() => {
			if (this._activeRequest === request) {
				request.handleError(new CancellationError());
				this._activeRequest = undefined;
			}

@chrmarti chrmarti added this pull request to the merge queue Feb 27, 2026
Merged via the queue into main with commit 77483a5 Feb 27, 2026
23 checks passed
@chrmarti chrmarti deleted the chrmarti/prime-dragon branch February 27, 2026 17:12
mexicodxnmexico-create added a commit to mexicodxnmexico-create/vscode-copilot-chat that referenced this pull request Feb 28, 2026
* Revert "cli - do not trust empty changes (microsoft/vscode#297975) (microsoft#4036)" (microsoft#4063)

This reverts commit 420c26f.

* Run command tool should include command result (microsoft#4061)

* Run command tool should include command result
Part of microsoft/vscode#298181

* CCR feedback

* Support CAPI WebSocket connections (microsoft#4068) (microsoft#4069)

* Add a maximum date of the comparison commit for the 1p repo telemetry info (microsoft#3774)

* initial passes with copilot before testing

* only pass on successful date

* add tests for new functionality

* return tooOld for all date failures

* remove extra logging, info is already in telemetry and may be too noisy

* fix test that used custom repo mock

---------

Co-authored-by: Ian Huff <ianhuff@Mac.home>
Co-authored-by: Ian Huff <ianhuff@Ians-MacBook-Pro-2.local>

* 0.39.0 (microsoft#4057)

* Make auto have provider affiniy (microsoft#4072)

* Pipe vendor from CAPI through to chat endpoint

* Adopt discussed auto mode behavior

* Update src/platform/endpoint/node/test/automodeService.spec.ts

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

---------

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

* Hold external repo info telemetry (microsoft#4075)

* Hold external repo info telemetry

* Update src/extension/prompt/node/repoInfoTelemetry.ts

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

* Update test to reflect no external telemetry for non-internal users

---------

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

* pass in the URL for the proxy to the CLI session (microsoft#4070)

* Update telemetry pkg (microsoft#4078)

* Merge agents and chatsession folder (microsoft#4058)

* Remove duplicated memory tool in picker (microsoft#4079)

* fixes microsoft/vscode#297010

* address feedback

* 🎨 Palette: Add aria-busy state to webview loading container

💡 What: Toggles `aria-busy` attribute on the `solutionsContainer` during async loading phases.
🎯 Why: To prevent screen reader users from experiencing silent, disorienting DOM changes when dynamic webview content updates.
♿ Accessibility: Improves loading state communication to assistive technologies.

Co-authored-by: mexicodxnmexico-create <245638303+mexicodxnmexico-create@users.noreply.github.com>

* Background - clean worktree changes cache at the end of the turn (microsoft#4083)

* 🎨 Palette: Add aria-busy state to webview loading container

💡 What: Toggles `aria-busy` attribute on the `solutionsContainer` during async loading phases.
🎯 Why: To prevent screen reader users from experiencing silent, disorienting DOM changes when dynamic webview content updates.
♿ Accessibility: Improves loading state communication to assistive technologies.

Co-authored-by: mexicodxnmexico-create <245638303+mexicodxnmexico-create@users.noreply.github.com>

---------

Co-authored-by: Benjamin Pasero <benjamin.pasero@microsoft.com>
Co-authored-by: Alex Ross <38270282+alexr00@users.noreply.github.com>
Co-authored-by: Christof Marti <chrmarti@microsoft.com>
Co-authored-by: Ian Huff <ian.huff@gmail.com>
Co-authored-by: Ian Huff <ianhuff@Mac.home>
Co-authored-by: Ian Huff <ianhuff@Ians-MacBook-Pro-2.local>
Co-authored-by: Ben Villalobos <bevillal@microsoft.com>
Co-authored-by: Logan Ramos <loganramos@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Zhichao Li <57812115+zhichli@users.noreply.github.com>
Co-authored-by: Aaron Munger <2019016+amunger@users.noreply.github.com>
Co-authored-by: Vijay Upadya <41652029+vijayupadya@users.noreply.github.com>
Co-authored-by: Don Jayamanne <don.jayamanne@outlook.com>
Co-authored-by: SteVen Batten <sbatten@microsoft.com>
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: mexicodxnmexico-create <245638303+mexicodxnmexico-create@users.noreply.github.com>
Co-authored-by: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com>
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.

4 participants