Skip to content

fix: Chronicle agent_name backfill, summary JSON filtering, schema description#313630

Merged
digitarald merged 2 commits intomainfrom
digitarald/agents/vscode-issue-312292-research-plan
May 1, 2026
Merged

fix: Chronicle agent_name backfill, summary JSON filtering, schema description#313630
digitarald merged 2 commits intomainfrom
digitarald/agents/vscode-issue-312292-research-plan

Conversation

@digitarald
Copy link
Copy Markdown
Contributor

Fixes the remaining open sub-issues of #312292 (Chronicle local schema drift).

Changes

extractAgentNamefixes #312296

sessions.agent_name was always 'unknown' in the local store because:

  1. _initSession fell through to 'unknown' when the span lacked gen_ai.agent.name
  2. _bufferSessionUpsert didn't include agent_name in its merge list, so later spans couldn't correct it

Fix: Add extractAgentName(span) with a fallback chain: attribute → span-name parsing ("invoke_agent copilot""copilot") → 'unknown'. Use it in _initSession, add agent_name to the _bufferSessionUpsert merge list (prerequisite for backfill to work), and backfill from _backfillFromSpanAttributes.

extractPlainTextFromContentfixes #312295

sessions.summary was stored verbatim from USER_REQUEST span attributes or first user message events, which can be structured JSON (e.g. [{"type":"tool_result","content":"..."}]). This broke LIKE-based queries and the FTS index.

Fix: Add extractPlainTextFromContent(content) that detects JSON content and extracts human-readable text from known structures (multi-modal text parts, chat message objects), returning undefined for unrecognized JSON (tool results, images, etc.) to skip the summary write entirely. Route all three summary write sites through it:

  • _backfillFromSpanAttributes (sessionStoreTracker.ts)
  • _handleAgentSpan (sessionStoreTracker.ts, both event and fallback paths)
  • processAssistantResponse summary path in sessionReindexer.ts (was missing from prior fix attempts)

Schema description — addresses #312292

Updated the local schema description in _getSchemaDescription():

  • agent_name: added example values ('GitHub Copilot Chat', 'copilotcli', 'claude')
  • host_type: noted it's always 'vscode' locally (not a distinguishing field)
  • summary: removed the raw JSON warning now that the write path filters it
  • search_index: clarified it indexes turns.user_message and turns.assistant_response content

Testing

16 new unit tests in sessionStoreTracking.spec.ts:

  • extractAgentName: attribute present, span-name fallback, multi-word names, empty suffix, empty attribute, non-invoke span
  • extractPlainTextFromContent: plain text, empty string, text parts, tool results, chat messages, array content, truncated JSON

…scription

- Add extractAgentName() with attribute → span-name → 'unknown' fallback; use
  in _initSession; add agent_name to _bufferSessionUpsert merge so backfill can
  overwrite initial 'unknown'; backfill from _backfillFromSpanAttributes.
  Fixes #312296.

- Add extractPlainTextFromContent() to skip tool-result JSON and extract text
  from multi-modal parts and chat messages; route all three summary write sites
  (_backfillFromSpanAttributes, _handleAgentSpan, sessionReindexer) through it.
  Fixes #312295.

- Update local schema description: agent_name example values, host_type always
  'vscode' locally, summary is plain text, search_index indexes turns content.
  Addresses #312292.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 1, 2026 03:20
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Screenshot Changes

Base: 32db9092 Current: a67b0e8c

Changed (2)

agentSessionsViewer/WithBadge/Dark
Before After
before after
agentSessionsViewer/WithBadge/Light
Before After
before after

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses remaining local Chronicle schema/data drift issues by improving how session agent_name and summary are populated from OTel spans, and by updating the Chronicle local schema prompt to better match actual stored data.

Changes:

  • Add extractAgentName(span) and wire it into session initialization, buffered upserts, and span-attribute backfill to enable sessions.agent_name correction/backfill.
  • Add extractPlainTextFromContent(content) and route all local sessions.summary write paths through it to avoid storing structured JSON blobs as summaries.
  • Update Chronicle local schema description text to reflect updated agent_name, summary, and search_index semantics.
Show a summary per file
File Description
extensions/copilot/src/extension/intents/node/chronicleIntent.ts Updates the local schema description text shown to the Chronicle intent LLM.
extensions/copilot/src/extension/chronicle/vscode-node/sessionStoreTracker.ts Uses new extraction helpers to populate/backfill agent_name and filter summary writes.
extensions/copilot/src/extension/chronicle/node/sessionReindexer.ts Filters summary generation during reindexing via extractPlainTextFromContent.
extensions/copilot/src/extension/chronicle/common/test/sessionStoreTracking.spec.ts Adds unit tests for extractAgentName and extractPlainTextFromContent.
extensions/copilot/src/extension/chronicle/common/sessionStoreTracking.ts Introduces the new extraction helpers shared by tracker and reindexer.

Copilot's findings

  • Files reviewed: 5/5 changed files
  • Comments generated: 2

Comment thread extensions/copilot/src/extension/chronicle/common/sessionStoreTracking.ts Outdated
Comment thread extensions/copilot/src/extension/intents/node/chronicleIntent.ts Outdated
roblourens
roblourens previously approved these changes May 1, 2026
…dex description

Address review feedback:
- extractPlainTextFromContent now returns undefined (skips summary write)
  when JSON-looking input fails to parse, preventing truncated JSON blobs
  from leaking into the summary column.
- search_index description now covers all indexed content: turns,
  checkpoint sections, and workspace artifacts with source_type.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@digitarald digitarald merged commit aeb8a3e into main May 1, 2026
26 checks passed
@digitarald digitarald deleted the digitarald/agents/vscode-issue-312292-research-plan branch May 1, 2026 04:54
@vs-code-engineering vs-code-engineering Bot added this to the 1.119.0 milestone May 1, 2026
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 Chronicle: sessions.summary contains raw JSON instead of human-readable text

4 participants