Fix tool-details undefined rendering + session metadata SQLite gap + metadata UI - #224
Merged
Merged
Conversation
…and add metadata UI Bug fix (root cause in agent-sdk, defense-in-depth here): - sanitizeTracePayload(undefined) used to throw inside JSON.parse and fall into a catch that returned String(undefined) -- the literal string "undefined" -- which then got object-spread into single-character indexed keys wherever a tool_call event's toolDetails was undefined (agent-sdk fix in a separate commit). client-tracing.ts and the session detail page now also guard event.toolDetails through the same toRecord()/getRecord() check metadata.toolDetails already went through, so a bad payload degrades to "no details" instead of exploding into characters. Real gap found and fixed: session-level `metadata` (added in the previous PR) was never persisted on SQLite -- the agent_tracing_sessions table had no metadata column, so every session created there silently dropped it on write. MongoDB's implicit whole-document persistence hid this. Added the column (fresh-DB schema + ensureTableColumn migration for existing DBs), wired it through create/update/row-mapping, and added a dual-backend regression test (tracing-session-metadata-parity.test.ts, 8 tests). New: - Session detail sidebar shows metadata (clicking a value jumps to the sessions list pre-filtered on it). - Sessions/threads list pages gained a metadata key+value filter, backed by Mongo `metadata.<key>` queries and SQLite json_extract, both validated against the same key charset the ingest sanitizer enforces. - Cost dashboard's per-model usage breakdown card gained a "Metadata" group-by option (existing Users/API keys toggle plus a key input); the backend route now accepts group_by=metadata.<key> via the same parseMetadataGroupByKey validator the client-facing API already used. Full suite green: 3215/3215 tests, tsc, eslint. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01R7LsJcWXZ2D9ZmhEWx1UVL
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.
Summary
Tool Details → Runtime Detailswas rendering the literal string"undefined"character-by-character as{0:"u",1:"n",...}whenever a tool_call event'stoolDetailswasundefined. Root cause is in agent-sdk'ssanitizeTracePayload(fixed in a separate agent-sdk commit/release); this PR adds defense-in-depth guards inclient-tracing.tsand the session detail page so a bad upstream payload degrades to "no details" instead of exploding into characters.metadata(added in Dynamic tracing-metadata usage attribution + fix Tracing Agents nav #222) was never persisted on SQLite —agent_tracing_sessionshad nometadatacolumn, so every session created there silently dropped it. MongoDB's implicit whole-document persistence hid this. Added the column + migration + wired it through create/update/row-mapping, with a new dual-backend regression test.metadata.<key>query / SQLitejson_extract, both key-charset validated); Cost dashboard's per-model usage breakdown card gained a "Metadata" group-by option next to Users/API keys.Test plan
npx tsc --noEmit— cleannpx eslinton touched files — clean (0 errors)npx vitest run— 3215/3215 passedtracing-session-metadata-parity.test.ts— 8/8 passed (create/findById round-trip, update round-trip, session search-by-metadata, thread search-by-metadata — each on both Mongo and SQLite)🤖 Generated with Claude Code
https://claude.ai/code/session_01R7LsJcWXZ2D9ZmhEWx1UVL