Skip to content

Emit parentRequestId on response.* events and from subagent loops - #314309

Merged
Isidor Nikolic (isidorn) merged 2 commits into
microsoft:mainfrom
kevin-m-kent:kevin-m-kent/telemetry-id-coverage
May 6, 2026
Merged

Isidor Nikolic (isidorn) merged 2 commits into
microsoft:mainfrom
kevin-m-kent:kevin-m-kent/telemetry-id-coverage

Conversation

@kevin-m-kent

@kevin-m-kent kevin-m-kent commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Aligns subagent correlation IDs across the chat telemetry pipeline. This allows us to group all requests associated with a single user interaction (via linking sub agents to main agents) for metrics like tokens or latencies per turn.

Changes

  • response.success: source parentRequestId from baseTelemetry.parentRequestId
  • response.cancelled / response.error: emit conversationId and parentRequestId.
  • executionSubagentToolCallingLoop / searchSubagentToolCallingLoop: set parentRequestId on telemetry properties from the parent ChatRequest.id, so subagent fetches actually carry the field.

After this, all three events carry the same parentRequestId semantic as panel.request: the chat request id of the parent that invoked the subagent.

Copilot AI review requested due to automatic review settings May 5, 2026 01:25

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

This PR updates Copilot chat fetch telemetry so failed and cancelled model requests carry the same conversation-linking identifiers that successful requests already use, improving correlation across parent/child agent requests in the prompt fetch pipeline.

Changes:

  • Adds conversationId and parentRequestId fields to response.cancelled and response.error telemetry payloads and GDPR metadata.
  • Adds a fallback parentRequestId source to response.success.
  • Threads the new telemetry properties through the cancellation/error call sites in chatMLFetcher.ts.
Show a summary per file
File Description
extensions/copilot/src/extension/prompt/node/chatMLFetcherTelemetry.ts Extends success/cancel/error telemetry payloads and GDPR schemas with conversation/parent request identifiers.
extensions/copilot/src/extension/prompt/node/chatMLFetcher.ts Passes conversation and parent request telemetry fields into cancellation/error emission paths.

Copilot's findings

Comments suppressed due to low confidence (1)

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

  • This duplicate cancellation path has the same gap as the one above: it only copies telemetryProperties.parentRequestId, even though the search/execution subagent loops set parentHeaderRequestId. Errors that are normalized to Canceled here will therefore still miss parentRequestId in telemetry for the main subagent flows.
						conversationId: telemetryProperties.conversationId ?? conversationId,
						associatedRequestId: telemetryProperties.associatedRequestId,
						parentRequestId: telemetryProperties.parentRequestId,
  • Files reviewed: 2/2 changed files
  • Comments generated: 2

transport,
conversationId: telemetryProperties.conversationId ?? conversationId,
associatedRequestId: telemetryProperties.associatedRequestId,
parentRequestId: telemetryProperties.parentRequestId,
...(fetcher ? { fetcher } : {}),
transport,
associatedRequestId: telemetryProperties?.associatedRequestId,
parentRequestId: telemetryProperties?.parentRequestId,
…uccess/cancelled/error

Today, response.success emits parentRequestId from baseTelemetry.parentHeaderRequestId,
which is the X-GitHub-Request-Id of the previous fetch (a per-fetch / call-level id),
not the parent turn. This doesn't match panel.request.parentRequestId, which uses
the VS Code chat API ChatRequest.parentRequestId (a per-turn, client-side id).

Switch response.success.parentRequestId to baseTelemetry.parentRequestId (sourced
from request.parentRequestId via defaultIntentRequestHandler), so it aligns with
panel.request.

Also emit parentRequestId and conversationId on response.cancelled and
response.error, sourced from the same telemetry properties, so cancelled/errored
requests can be correlated to a parent turn and conversation the same way
successful requests can.

Co-authored-by: Copilot <[email protected]>
@kevin-m-kent
kevin-m-kent force-pushed the kevin-m-kent/telemetry-id-coverage branch from 05a8147 to be69289 Compare May 5, 2026 01:33
@kevin-m-kent kevin-m-kent changed the title Emit conversationId/parentRequestId on response.cancelled and response.error Align response.success/cancelled/error parentRequestId with panel.request (VS Code chat parent turn id) May 5, 2026
The execution and search subagent tool-calling loops only populated
parentHeaderRequestId on their telemetry properties — not parentRequestId.
These loops are spawned directly from a parent turn's tool call (not via
the VS Code chat-agent mechanism), so VS Code core never sets
ChatRequest.parentRequestId on them. As a result, subagent
response.success/cancelled/error events would not carry the parent's
chat request id, breaking correlation back to the parent.

Set parentRequestId from this.options.request.id (the parent
ChatRequest's id) so subagent telemetry consistently carries the parent
correlation id alongside parentHeaderRequestId.

Co-authored-by: Copilot <[email protected]>
@kevin-m-kent kevin-m-kent changed the title Align response.success/cancelled/error parentRequestId with panel.request (VS Code chat parent turn id) Emit parentRequestId on response.* events and from subagent loops May 5, 2026
@isidorn

Copy link
Copy Markdown

This one makes a lot of sense to me -> approved. Assigning to Rob to get his thoughts

@roblourens

Copy link
Copy Markdown
Member

Seems fine, feel free to merge

@isidorn
Isidor Nikolic (isidorn) merged commit a9b3c39 into microsoft:main May 6, 2026
26 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.120.0 milestone May 6, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jun 20, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants