Fix BYOK response success turn telemetry#319637
Merged
Merged
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR adds end-to-end propagation of a “conversation turn” value from chat request telemetry properties into VS Code model options and then into BYOK provider telemetry measurements.
Changes:
- Extend request telemetry properties and OTel model options to carry a turn index/measurement.
- Forward
turnIndexfrommakeChatRequest2intomodelOptions._telemetryTurn. - Emit the forwarded turn as a
turnmeasurement in Anthropic/Gemini providerresponse.successtelemetry, with new tests covering the forwarding path and Gemini emission.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/platform/otel/common/otelService.ts | Adds _telemetryTurn to OTel model options for turn propagation. |
| extensions/copilot/src/platform/networking/common/networking.ts | Adds turnIndex to chat request telemetry properties. |
| extensions/copilot/src/platform/endpoint/vscode-node/test/extChatEndpoint.spec.ts | Adds a unit test verifying turn forwarding into modelOptions. |
| extensions/copilot/src/platform/endpoint/vscode-node/extChatEndpoint.ts | Extracts/parses turnIndex and injects _telemetryTurn into model options. |
| extensions/copilot/src/extension/prompt/node/defaultIntentRequestHandler.ts | Populates turnIndex when emitting request telemetry. |
| extensions/copilot/src/extension/byok/vscode-node/test/geminiNativeProvider.spec.ts | Adds a test verifying Gemini emits turn measurement on response.success. |
| extensions/copilot/src/extension/byok/vscode-node/geminiNativeProvider.ts | Reads _telemetryTurn and emits it as turn measurement. |
| extensions/copilot/src/extension/byok/vscode-node/anthropicProvider.ts | Reads _telemetryTurn and emits it as turn measurement. |
Copilot's findings
Comments suppressed due to low confidence (2)
extensions/copilot/src/extension/byok/vscode-node/geminiNativeProvider.ts:1
telemetryTurnisnumber | undefined, but telemetry “measurements” are typically expected to be numeric-only. Sending{ turn: undefined }can break downstream serialization or violate the measurements type contract. Prefer conditionally addingturnonly whentelemetryTurnis a valid number (e.g., using a conditional spread when building the measurements object).
/*---------------------------------------------------------------------------------------------
extensions/copilot/src/extension/byok/vscode-node/anthropicProvider.ts:1
- Same issue as Gemini:
telemetryTurnis optional, but the measurements payload should avoidundefinedvalues. Build the measurements object soturnis included only whentelemetryTurnis a valid number.
/*---------------------------------------------------------------------------------------------
- Files reviewed: 8/8 changed files
- Comments generated: 2
Comment on lines
+313
to
+320
| function getTelemetryTurnFromProperties(telemetryProperties: IMakeChatRequestOptions['telemetryProperties']): number | undefined { | ||
| if (typeof telemetryProperties?.turnIndex !== 'string') { | ||
| return undefined; | ||
| } | ||
|
|
||
| const turn = Number(telemetryProperties.turnIndex); | ||
| return Number.isFinite(turn) ? turn : undefined; | ||
| } |
| requestId, | ||
| }, { | ||
| totalTokenMax: model.maxInputTokens ?? -1, | ||
| turn: telemetryTurn, |
Collaborator
|
@tbogoodnews I just reviewed the PR and it looks good.
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collaborator
|
@vritant24 can you help review this one? |
vritant24
approved these changes
Jun 4, 2026
vritant24
approved these changes
Jun 4, 2026
Member
|
LGTM @tbogoodnews |
isidorn
approved these changes
Jun 4, 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.
Summary
Adds the missing
turnmeasurement togithub.copilot-chat/response.successtelemetry for BYOK chat responses, matching the turn value already sent bygithub.copilot-chat/panel.request.Problem
github.copilot-chat/panel.requestreports the conversation turn, but BYOKgithub.copilot-chat/response.successtelemetry did not include the same value inMeasures. This made it harder to correlate request and response events.Changes
turnIndex.Measures.turnon Gemini and Anthropic BYOKresponse.successtelemetry.response.successfires withMeasures.turn.Related issue
https://github.com/microsoft/vscode-internalbacklog/issues/7765