agentHost: Track tool result size - #328866
Draft
amunger wants to merge 1 commit into
Draft
Conversation
Add a serialized result-size measurement to languageModelToolInvoked so Agent Host telemetry preserves tool response-size analysis without duplicating the legacy event schema. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds serialized Agent Host tool-result size telemetry to the canonical languageModelToolInvoked event.
Changes:
- Measures
ToolCallResultJSON length in UTF-16 code units. - Propagates the measurement through Agent Host telemetry.
- Tests successful, failed, client, and content-bearing results.
Show a summary per file
| File | Description |
|---|---|
languageModelToolTelemetry.ts |
Defines and classifies the new measurement. |
agentHostToolCallTelemetry.test.ts |
Verifies emitted result sizes. |
agentHostToolCallTracker.ts |
Computes serialized result length. |
agentHostTelemetryReporter.ts |
Emits the measurement. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 0
- Review effort level: Balanced
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.
Overview
What
Adds
resultSizeInCharactersto the canonicallanguageModelToolInvokedevent for Agent Host tool completions. The measurement is computed as the serialized AHPToolCallResultlength in UTF-16 code units and flows through the existingAgentSideEffects->AgentHostToolCallTracker->AgentHostTelemetryReporterpath.This preserves the result-size analysis currently provided locally by
agent.tool.responseLengthwithout duplicating that legacy event name or schema. The local emitter is unchanged.Follow-up work may add tokenizer-aware result cost, model identity, and request-level correlation if those dimensions are needed. They are deliberately not represented by placeholders here.
Why
Tracked in https://github.com/microsoft/vscode-internalbacklog/issues/8247. The local event was observed in local sessions but had no Agent Host counterpart, leaving tool-result-size analysis dark for AH traffic. Character count is an honest close analogue that supports relative size distributions while keeping the unit difference explicit.
Data parity
Legend: ✅ = same analytical signal, ≈ = close analogue, ⊗ = AH data omits.
agent.tool.responseLength.toolNamelanguageModelToolInvoked.toolIdlanguageModelToolInvoked.result == "success"tokenCountresultSizeInCharactersmodelconversationId,requestIdchatSessionIdonlyRow-count and dashboard implications
agent.tool.responseLengthremains success-only and token-based.languageModelToolInvokedcovers successful, failed, and user-cancelled completed tool calls; filter toresult == "success"for population parity.toolName = coalesce(toolName, toolId)and retain an explicit size-unit dimension. Do not coalesce raw token and character counts into one numeric series.Semantic-shift ledger
Validation
scripts/test.bat --run src/vs/platform/agentHost/test/node/agentHostToolCallTelemetry.test.ts— 14 passingnpm run precommit— passednpm run typecheck-clientandnpm run valid-layers-checkwere attempted but are currently blocked by unrelated pre-existing Agent Host protocol type errors incopilotAgentSession.ts,copilotSystemNotification.ts, andfixtureUtils.ts.