Skip to content

Chronicle: fix sessions.summary storing raw JSON instead of human-readable text#312298

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/fix-sessions-summary-json-issue
Draft

Chronicle: fix sessions.summary storing raw JSON instead of human-readable text#312298
Copilot wants to merge 2 commits intomainfrom
copilot/fix-sessions-summary-json-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 24, 2026

sessions.summary was being populated 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 confused the Chronicle intent LLM.

Changes

  • New helper extractPlainTextFromContent (sessionStoreTracking.ts): detects JSON content (starts with [ or {) and extracts human-readable text from known message structures:

    • {"type":"text","text":"..."} — multi-modal text parts
    • {"role":"...","content":"..."} — chat messages with string content
    • Returns undefined for unrecognized JSON (tool results, images, etc.), skipping the summary entirely
    • Falls back to original string if JSON parsing fails
  • _backfillFromSpanAttributes and _handleAgentSpan now route through the helper before setting summary, and skip the write when undefined is returned

  • 13 new tests in sessionStoreTracking.spec.ts covering plain text pass-through, text part/chat message extraction, tool result skipping, empty/invalid JSON, and whitespace handling

// Before: stored verbatim
summary = '[{"type":"tool_result","content":"..."}]'

// After: skipped (no human-readable text extractable from tool_result JSON)
summary = undefined

// Text parts and chat messages are still extracted correctly
extractPlainTextFromContent('[{"type":"text","text":"Fix the login bug"}]')
// → "Fix the login bug"

Copilot AI requested review from Copilot and removed request for Copilot April 24, 2026 04:42
Copilot AI changed the title [WIP] Fix sessions.summary containing raw JSON instead of human-readable text Chronicle: fix sessions.summary storing raw JSON instead of human-readable text Apr 24, 2026
Copilot AI requested a review from digitarald April 24, 2026 04:43
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: sessions.summary contains raw JSON instead of human-readable text

2 participants