Chronicle: populate agent_name on sessions from invoke_agent spans#312300
Draft
Chronicle: populate agent_name on sessions from invoke_agent spans#312300
Conversation
… fallback - Add extractAgentName() to sessionStoreTracking.ts: reads gen_ai.agent.name attribute first, falls back to parsing the span name (e.g. "invoke_agent copilot" → "copilot"), then returns "unknown" as last resort - Update _initSession to use extractAgentName() instead of direct attribute read - Backfill agent_name in _backfillFromSpanAttributes for subsequent invoke_agent spans - Add agent_name to _bufferSessionUpsert merge logic to allow backfill updates - Add 8 unit tests for extractAgentName in sessionStoreTracking.spec.ts Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/31503892-0771-4329-88a1-e1a084555df2 Co-authored-by: digitarald <8599+digitarald@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix session agent_name population from invoke_agent spans
Chronicle: populate agent_name on sessions from invoke_agent spans
Apr 24, 2026
vijayupadya
approved these changes
Apr 24, 2026
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.
sessions.agent_namewas always'unknown'in the local Chronicle store because_initSessionreadgen_ai.agent.namewith no fallback, and this attribute isn't guaranteed on all invoke_agent spans.Changes
sessionStoreTracking.ts: Adds exportedextractAgentName(span)pure function — readsgen_ai.agent.nameattribute first, then falls back to parsing the span name ("invoke_agent copilot"→"copilot"), finally"unknown". Same fallback pattern used byotelSpanToChatDebugEvent.ts.sessionStoreTracker.ts:_initSession: usesextractAgentName()instead of bare attribute read_backfillFromSpanAttributes: also extracts and buffersagent_namefrom subsequent invoke_agent spans, so later turns can correct an initial'unknown'_bufferSessionUpsert: addsagent_nameto the selective merge list so backfill writes can overwrite itsessionStoreTracking.spec.ts(new): 8 unit tests covering attribute-present, span-name fallback, whitespace edge cases, and'unknown'last resort.