Skip to content

Chronicle: populate agent_name on sessions from invoke_agent spans#312300

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/populate-agent-name-on-sessions
Draft

Chronicle: populate agent_name on sessions from invoke_agent spans#312300
Copilot wants to merge 2 commits intomainfrom
copilot/populate-agent-name-on-sessions

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 24, 2026

sessions.agent_name was always 'unknown' in the local Chronicle store because _initSession read gen_ai.agent.name with no fallback, and this attribute isn't guaranteed on all invoke_agent spans.

Changes

  • sessionStoreTracking.ts: Adds exported extractAgentName(span) pure function — reads gen_ai.agent.name attribute first, then falls back to parsing the span name ("invoke_agent copilot""copilot"), finally "unknown". Same fallback pattern used by otelSpanToChatDebugEvent.ts.

  • sessionStoreTracker.ts:

    • _initSession: uses extractAgentName() instead of bare attribute read
    • _backfillFromSpanAttributes: also extracts and buffers agent_name from subsequent invoke_agent spans, so later turns can correct an initial 'unknown'
    • _bufferSessionUpsert: adds agent_name to the selective merge list so backfill writes can overwrite it
  • sessionStoreTracking.spec.ts (new): 8 unit tests covering attribute-present, span-name fallback, whitespace edge cases, and 'unknown' last resort.

Copilot AI requested review from Copilot and removed request for Copilot April 24, 2026 04:34
Copilot AI linked an issue Apr 24, 2026 that may be closed by this pull request
… 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 requested review from Copilot and removed request for Copilot April 24, 2026 04:54
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
Copilot AI requested a review from digitarald April 24, 2026 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chronicle: populate agent_name on sessions from invoke_agent spans

3 participants