gen_ai.agent.name never reflects the active custom agent for top-level (non-subagent) sessions
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
Copilot Chat's OTel export (`docs/monitoring/agent_monitoring.md`) documents `gen_ai.agent.name` as required on `invoke_agent` spans and the `copilot_chat.agent.*` metrics. In practice, for a session where the user has directly selected a custom `.agent.md` agent (not one dispatched via `runSubagent`), this field is always the generic `"GitHub Copilot Chat"` — including for `copilot_chat.session.start`, `copilot_chat.agent.turn.count`, and `copilot_chat.agent.invocation.duration` — never the actual persona's name.
Confirmed against a real 22,950-line/242MB capture: zero occurrences of a directly-selected custom agent's real name anywhere in the file, across every `session.start` event. Subagents dispatched via `runSubagent` *do* get real names in the same file (11k+ occurrences), confirming the identity-threading mechanism exists — it's just not wired up for the foreground/top-level case.
Root cause, from source (as it stood in the former `microsoft/vscode-copilot-chat` repo, prior to archival — same logic should now live under this repo's Copilot Chat extension code): `provideCustomAgents()` (e.g. `githubOrgCustomAgentProvider.ts`, the local-file equivalent) returns bare file URIs, not distinct `vscode.ChatParticipant` registrations — VS Code loads the `.agent.md` content as a persona layered onto one fixed shared participant (`editsAgent`, see `chatAgents.ts`). `emitSessionStartEvent()` (`genAiEvents.ts`) derives `gen_ai.agent.name` from that participant, so every directly-selected custom agent collapses to the same generic identity regardless of which persona is actually active.
This is also user-visible in a confusing way: the agent will correctly self-report its real persona name in chat if asked directly ("Which agent are you?" → "JARVIS"), since that's a prompt-layer fact the model has — but that identity never makes it into the telemetry layer.
**Ask:** thread the active custom agent's real name into `gen_ai.agent.name` for top-level/foreground sessions too, not just `runSubagent`-dispatched ones — the persona is already known internally (it's driving the system prompt and tool list), it's just not being surfaced to the OTel identity fields.
Contributor guide
Assessment
This issue has not been assessed yet.