Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add requestKind to chat response telemetry events#312262

Open
kevin-m-kent wants to merge 1 commit intomicrosoft:mainfrom
kevin-m-kent:kevin-m-kent/telemetry-request-kind
Open

Add requestKind to chat response telemetry events#312262
kevin-m-kent wants to merge 1 commit intomicrosoft:mainfrom
kevin-m-kent:kevin-m-kent/telemetry-request-kind

Conversation

@kevin-m-kent
Copy link
Copy Markdown
Contributor

Emit a new requestKind property on response.success, response.cancelled, and response.error telemetry events. Values are 'background', 'subagent', or 'normal', derived from the same requestKindOptions that already sets the outgoing X-Interaction-Type header in CAPI requests.

Motivation

Today we can tell from telemetry whether a chat request was initiated by the user vs. an agent tool call (via initiatorType), but we can't distinguish which agent requests are background (speculative/system) vs. subagent (spawned by a parent agent) vs. normal primary-turn requests. That signal is already on the wire as the X-Interaction-Type header, but it isn't logged client-side. This makes it hard to slice perf / success metrics by request kind.

Changes

extensions/copilot/src/extension/prompt/node/chatMLFetcherTelemetry.ts

  • Adds requestKindOptions to IChatMLFetcherSuccessfulData, IChatMLFetcherCancellationProperties, IChatMLFetcherErrorData.
  • Emits requestKind: requestKindOptions?.kind ?? 'normal' on response.success, response.cancelled, response.error.
  • Adds the property to each event's __GDPR__ schema (classification SystemMetaData, purpose FeatureInsight).

extensions/copilot/src/extension/prompt/node/chatMLFetcher.ts

  • Threads requestKindOptions (already destructured at the top of fetchMany) into all five call sites: the success, cancel, and error calls in fetchMany and _retryAfterError, plus the new processSuccessfulResponse parameter.

Notes

  • BYOK (Anthropic / Gemini native) providers declare initiatorType in their response.success GDPR schema but don't actually emit it today; intentionally leaving BYOK out of this PR to keep it scoped to the CAPI path.
  • No behavior change; telemetry-only.

Emit a new 'requestKind' property on response.success, response.cancelled,
and response.error. Values: 'background', 'subagent', or 'normal' (derived
from the same requestKindOptions that sets the X-Interaction-Type header).

This lets us distinguish background and subagent requests from primary user
requests in telemetry, complementing the existing initiatorType (user/agent)
signal.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings April 23, 2026 23:34
Copy link
Copy Markdown
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

This PR extends Copilot chat response telemetry to include a requestKind dimension ('normal' | 'background' | 'subagent') on the CAPI path, derived from existing requestKindOptions that already influence the X-Interaction-Type header. This enables slicing success/cancel/error metrics by request kind without changing runtime behavior.

Changes:

  • Adds requestKindOptions to the telemetry payload interfaces and emits requestKind on response.success, response.cancelled, and response.error.
  • Updates the GDPR schemas for the three events to include requestKind (SystemMetaData / FeatureInsight).
  • Threads requestKindOptions through ChatMLFetcherImpl success/cancel/error telemetry call paths (including retry/error paths).
Show a summary per file
File Description
extensions/copilot/src/extension/prompt/node/chatMLFetcherTelemetry.ts Adds requestKind emission and GDPR schema entries for success/cancel/error response telemetry.
extensions/copilot/src/extension/prompt/node/chatMLFetcher.ts Passes requestKindOptions through to telemetry senders and into processSuccessfulResponse.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

@kevin-m-kent
Copy link
Copy Markdown
Contributor Author

@roblourens curious what you think of this. We are looking to filter out background requests in a robust way for our A/Bs, rather than maintain a list of sources. Copilot seems to think that this header for background interaction type never actually fires, but I'm suspicious of that claim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants