Record CAPI X-Copilot-Service-Request-Id on chat telemetry events - #334638
Merged
Vijay Upadya (vijayupadya) merged 2 commits intoSep 6, 2026
Merged
Conversation
Copilot started reviewing on behalf of
Rohit Agrawal - MSFT (rohit489)
September 4, 2026 22:04
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Several filtering, cancellation, and failed-connectivity paths still discard the new correlation ID.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 2
New issues introduced by this change (2)
| Severity | Finding |
|---|---|
extensions/copilot/src/extension/prompt/node/chatMLFetcher.ts — The FetchResponseKind.Failed retry caller destructures only retryResult from… |
|
extensions/copilot/src/extension/prompt/node/chatMLFetcherTelemetry.ts — This new cancellation property is populated only by the exception/catch cancellation path. The… |
What changed in this PR
Adds CAPI service request IDs to chat results and telemetry for cross-system correlation.
Changes:
- Extracts and propagates
X-Copilot-Service-Request-Id. - Adds IDs to HTTP, WebSocket, retry, cancellation, and error telemetry.
- Updates tests, fixtures, and snapshots.
| File | Description |
|---|---|
extensions/copilot/src/platform/telemetry/common/telemetryData.ts |
Adds the ID to request telemetry data. |
extensions/copilot/src/platform/networking/test/node/fetch.spec.ts |
Tests header extraction and casing. |
extensions/copilot/src/platform/networking/node/chatWebSocketTelemetry.ts |
Adds the ID to WebSocket events. |
extensions/copilot/src/platform/networking/node/chatWebSocketManager.ts |
Captures the handshake ID. |
extensions/copilot/src/platform/networking/common/networking.ts |
Extends retry telemetry properties. |
extensions/copilot/src/platform/networking/common/fetch.ts |
Defines extraction helpers and request metadata. |
extensions/copilot/src/platform/endpoint/test/node/messagesApi.spec.ts |
Updates processor construction. |
extensions/copilot/src/platform/endpoint/test/node/__snapshots__/stream.sseProcessor.spec.ts.snap |
Updates request metadata snapshots. |
extensions/copilot/src/platform/endpoint/node/test/responsesApiToolSearch.spec.ts |
Updates Responses processor fixtures. |
extensions/copilot/src/platform/endpoint/node/test/responsesApi.spec.ts |
Updates Responses processor tests. |
extensions/copilot/src/platform/endpoint/node/responsesApi.ts |
Propagates the ID through Responses completions. |
extensions/copilot/src/platform/endpoint/node/messagesApi.ts |
Propagates the ID through Anthropic completions. |
extensions/copilot/src/platform/endpoint/node/chatEndpoint.ts |
Adds the ID to non-streaming completions. |
extensions/copilot/src/platform/chat/common/commonTypes.ts |
Extends chat result types. |
extensions/copilot/src/extension/prompt/node/test/chatMLFetcherResponseApiTelemetry.spec.ts |
Verifies success telemetry correlation. |
extensions/copilot/src/extension/prompt/node/chatMLFetcherTelemetry.ts |
Extends chat telemetry event schemas. |
extensions/copilot/src/extension/prompt/node/chatMLFetcher.ts |
Threads IDs through fetch and retry paths. |
extensions/copilot/src/extension/externalAgents/node/oaiLanguageModelServer.ts |
Propagates IDs for external-agent streaming. |
extensions/copilot/src/extension/completions-core/vscode-node/lib/src/test/fetcher.ts |
Updates completion test metadata. |
extensions/copilot/src/extension/completions-core/vscode-node/lib/src/openai/fetch.fake.ts |
Updates fake completion metadata. |
extensions/copilot/src/extension/completions-core/vscode-node/lib/src/ghostText/test/streamedCompletionSplitter.test.ts |
Updates ghost-text test metadata. |
Suppressed comments (1)
extensions/copilot/src/extension/prompt/node/chatMLFetcher.ts:1938
- The service request ID is added to
FilteredRetry, but the conversion to the finalFilteredresult at lines 379–385 copies onlyrequestIdandserverRequestId. When filtering is not retried (or no retry result is returned), callers therefore still lose the CAPI correlation ID. Forwardresult.copilotServiceRequestIdin that returned result as well.
copilotServiceRequestId: result.requestId.copilotServiceRequestId,
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+873
to
+876
| const connectivityTestErrorCopilotServiceRequestId = connectivity.connectivityTestErrorCopilotServiceRequestId; | ||
| if (!connectivity.retryRequest) { | ||
| this._logService.info(`Not retrying chat request as network connectivity could not be re-established.`); | ||
| return { connectivityTestError, connectivityTestErrorGitHubRequestId }; | ||
| return { connectivityTestError, connectivityTestErrorGitHubRequestId, connectivityTestErrorCopilotServiceRequestId }; |
| export interface IChatMLFetcherCancellationProperties { | ||
| source: string; | ||
| requestId: string; | ||
| copilotServiceRequestId?: string; |
Vijay Upadya (vijayupadya)
approved these changes
Sep 4, 2026
Dmitriy Vasyura (dmitrivMS)
approved these changes
Sep 5, 2026
roblourens
approved these changes
Sep 6, 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.

Captures CAPI's X-Copilot-Service-Request-Id response header and threads it through chat fetch results, error paths, and websocket telemetry, so client-side telemetry events can be joined with CAPI's telemtry.
Also covers the retry-after-error and connectivity-test error paths, and adds a test asserting the id lands on chat response telemetry.