Yemohyle/add to ext telemetrey#313159
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends Copilot extension and internal model-call telemetry to better correlate subagent requests and tool-calling iterations by propagating a modelCallId plus new parent/iteration linking fields through the request/response pipeline.
Changes:
- Adds
modelCallIdto successful fetch results and forwards it intoresponse.successtelemetry. - Propagates
parentModelCallIdanditerationNumberthrough tool-calling loops and subagent tool invocations. - Enriches internal
model.modelCall.input/outputtelemetry withparentModelCallIdanditerationNumber.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/platform/networking/node/chatStream.ts | Adds parentModelCallId and iterationNumber to internal model.modelCall.* telemetry events. |
| extensions/copilot/src/platform/networking/common/networking.ts | Extends IChatRequestTelemetryProperties with parentModelCallId and iterationNumber. |
| extensions/copilot/src/platform/chat/common/commonTypes.ts | Adds optional modelCallId to success fetch results. |
| extensions/copilot/src/extension/tools/node/searchSubagentTool.ts | Passes parentModelCallId into subagent invocation telemetry context. |
| extensions/copilot/src/extension/tools/node/executionSubagentTool.ts | Passes parentModelCallId into subagent invocation telemetry context. |
| extensions/copilot/src/extension/prompt/node/searchSubagentToolCallingLoop.ts | Threads parentModelCallId and iterationNumber into subagent requests’ telemetry properties. |
| extensions/copilot/src/extension/prompt/node/executionSubagentToolCallingLoop.ts | Threads parentModelCallId and iterationNumber into subagent requests’ telemetry properties. |
| extensions/copilot/src/extension/prompt/node/defaultIntentRequestHandler.ts | Adds iterationNumber to main request telemetry properties. |
| extensions/copilot/src/extension/prompt/node/chatMLFetcherTelemetry.ts | Adds new response.success telemetry fields (including modelCallId, parent linking, iteration). |
| extensions/copilot/src/extension/prompt/common/intents.ts | Extends prompt context to carry parentModelCallId for downstream subagent tools. |
| extensions/copilot/src/extension/intents/node/toolCallingLoop.ts | Tracks last headerRequestId and modelCallId from successful fetches and passes them via prompt context; threads iterationNumber through fetch options. |
Copilot's findings
- Files reviewed: 12/12 changed files
- Comments generated: 3
| modelCallId, | ||
| ...(baseTelemetry?.properties.subType ? { subType: baseTelemetry.properties.subType } : {}), | ||
| ...(baseTelemetry?.properties.parentHeaderRequestId ? { parentRequestId: baseTelemetry.properties.parentHeaderRequestId } : {}), | ||
| ...(baseTelemetry?.properties.parentModelCallId ? { parentModelCallId: baseTelemetry.properties.parentModelCallId } : {}), | ||
| ...(baseTelemetry?.properties.iterationNumber ? { iterationNumber: baseTelemetry.properties.iterationNumber } : {}), |
There was a problem hiding this comment.
PR description says response.success.subType should be one of "subagent" / "system-initiated" / absent, but this code forwards baseTelemetry.properties.subType verbatim. Existing callers set more specific values like subagent/search and subagent/execution, which will now surface in response.success and may violate the intended schema. If the event needs a stable, low-cardinality enum, consider normalizing here (e.g. map any subagent/* to subagent).
| // Store the server-echoed headerRequestId from the fetch response for subagent telemetry linking. | ||
| // Prefer serverRequestId (the server's x-request-id response header) because it matches | ||
| // chatCompletion.requestId.headerRequestId which is reported as `requestId` in response.success. | ||
| // Fall back to requestId (client-generated UUID) if the server didn't echo the header. | ||
| if (fetchResult.type === ChatFetchResponseType.Success) { | ||
| this.lastHeaderRequestId = fetchResult.requestId; | ||
| this.lastHeaderRequestId = fetchResult.serverRequestId ?? fetchResult.requestId; | ||
| this.lastModelCallId = fetchResult.modelCallId; | ||
| } |
There was a problem hiding this comment.
The new propagation/storage of lastModelCallId and the revised parent header request id selection are not covered by existing ToolCallingLoop unit tests. Adding a focused test that runs two iterations and asserts that createPromptContext() exposes parentHeaderRequestId/parentModelCallId from the previous successful fetch (including the fallback behavior) would help prevent regressions in subagent telemetry linking.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
774d100 to
681fab1
Compare
New fields in VSCodeExt telemetry event response.success:
modelCallId -- unique ID for this model call (surfaced from the fetcher)
subType -- "subagent/search" / "subagent/search" / absent
parentRequestId -- parent's requestId (enables child.parentRequestId = parent.requestId joins)
parentModelCallId -- parent's modelCallId (links to exact model call that spawned subagent)
iterationNumber -- 0-based tool-calling loop iteration
New fields in VSCode internal telemetry event model.modelCall.input/output:
parentModelCallId -- parent's modelCallId
iterationNumber -- 0-based tool-calling loop iteration