fix: Chronicle agent_name backfill, summary JSON filtering, schema description#313630
Merged
digitarald merged 2 commits intomainfrom May 1, 2026
Merged
Conversation
…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>
Contributor
Contributor
There was a problem hiding this comment.
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 enablesessions.agent_namecorrection/backfill. - Add
extractPlainTextFromContent(content)and route all localsessions.summarywrite paths through it to avoid storing structured JSON blobs as summaries. - Update Chronicle local schema description text to reflect updated
agent_name,summary, andsearch_indexsemantics.
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
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>
vijayupadya
approved these changes
May 1, 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.
Fixes the remaining open sub-issues of #312292 (Chronicle local schema drift).
Changes
extractAgentName— fixes #312296sessions.agent_namewas always'unknown'in the local store because:_initSessionfell through to'unknown'when the span lackedgen_ai.agent.name_bufferSessionUpsertdidn't includeagent_namein its merge list, so later spans couldn't correct itFix: Add
extractAgentName(span)with a fallback chain: attribute → span-name parsing ("invoke_agent copilot"→"copilot") →'unknown'. Use it in_initSession, addagent_nameto the_bufferSessionUpsertmerge list (prerequisite for backfill to work), and backfill from_backfillFromSpanAttributes.extractPlainTextFromContent— fixes #312295sessions.summarywas stored verbatim fromUSER_REQUESTspan attributes or first user message events, which can be structured JSON (e.g.[{"type":"tool_result","content":"..."}]). This brokeLIKE-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), returningundefinedfor 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)processAssistantResponsesummary 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 itsearch_index: clarified it indexesturns.user_messageandturns.assistant_responsecontentTesting
16 new unit tests in
sessionStoreTracking.spec.ts:extractAgentName: attribute present, span-name fallback, multi-word names, empty suffix, empty attribute, non-invoke spanextractPlainTextFromContent: plain text, empty string, text parts, tool results, chat messages, array content, truncated JSON