Skip to content

Fix BYOK response success turn telemetry#319637

Merged
isidorn merged 4 commits into
microsoft:mainfrom
tbogoodnews:main
Jun 4, 2026
Merged

Fix BYOK response success turn telemetry#319637
isidorn merged 4 commits into
microsoft:mainfrom
tbogoodnews:main

Conversation

@tbogoodnews

Copy link
Copy Markdown
Contributor

Summary

Adds the missing turn measurement to github.copilot-chat/response.success telemetry for BYOK chat responses, matching the turn value already sent by github.copilot-chat/panel.request.

Problem

github.copilot-chat/panel.request reports the conversation turn, but BYOK github.copilot-chat/response.success telemetry did not include the same value in Measures. This made it harder to correlate request and response events.

Changes

  • Carries the panel request turn through request telemetry as turnIndex.
  • Bridges that value through extension-contributed chat endpoint model options.
  • Emits Measures.turn on Gemini and Anthropic BYOK response.success telemetry.
  • Keeps tool-call iteration telemetry separate from conversation turn telemetry.
  • Adds regression tests confirming the endpoint forwards the turn and that response.success fires with Measures.turn.

Related issue

https://github.com/microsoft/vscode-internalbacklog/issues/7765

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 2, 2026 19:46

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

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 turnIndex from makeChatRequest2 into modelOptions._telemetryTurn.
  • Emit the forwarded turn as a turn measurement in Anthropic/Gemini provider response.success telemetry, 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

  • telemetryTurn is number | 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 adding turn only when telemetryTurn is 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: telemetryTurn is optional, but the measurements payload should avoid undefined values. Build the measurements object so turn is included only when telemetryTurn is 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,
@isidorn

isidorn commented Jun 3, 2026

Copy link
Copy Markdown
Collaborator

@tbogoodnews I just reviewed the PR and it looks good.

  1. Have you tested out from source that it works as expected? https://github.com/microsoft/vscode/wiki/How-to-Contribute
  2. Can you tackle the GH Copilot comments on this PR? Or mark them as resolved in case they should not be addressed

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@isidorn isidorn assigned vritant24 and unassigned isidorn Jun 4, 2026
@isidorn

isidorn commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

@vritant24 can you help review this one?

@vritant24

Copy link
Copy Markdown
Member

LGTM @tbogoodnews

@isidorn isidorn enabled auto-merge June 4, 2026 18:08
@isidorn isidorn merged commit d026db2 into microsoft:main Jun 4, 2026
25 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.124.0 milestone Jun 4, 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.

5 participants