Skip to content

Fix tool-details undefined rendering + session metadata SQLite gap + metadata UI - #224

Merged
anilguleroglu merged 1 commit into
mainfrom
fix/tracing-metadata-bug-and-ui
Aug 17, 2026
Merged

Fix tool-details undefined rendering + session metadata SQLite gap + metadata UI#224
anilguleroglu merged 1 commit into
mainfrom
fix/tracing-metadata-bug-and-ui

Conversation

@anilguleroglu

Copy link
Copy Markdown
Collaborator

Summary

  • Bug fix: Tool Details → Runtime Details was rendering the literal string "undefined" character-by-character as {0:"u",1:"n",...} whenever a tool_call event's toolDetails was undefined. Root cause is in agent-sdk's sanitizeTracePayload (fixed in a separate agent-sdk commit/release); this PR adds defense-in-depth guards in client-tracing.ts and the session detail page so a bad upstream payload degrades to "no details" instead of exploding into characters.
  • Real gap found & fixed: session-level metadata (added in Dynamic tracing-metadata usage attribution + fix Tracing Agents nav #222) was never persisted on SQLite — agent_tracing_sessions had no metadata column, 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.
  • New UI: session detail sidebar shows metadata (click a value → jump to the sessions list pre-filtered on it); sessions/threads list pages gained a metadata key+value filter (Mongo metadata.<key> query / SQLite json_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 — clean
  • npx eslint on touched files — clean (0 errors)
  • Full suite: npx vitest run — 3215/3215 passed
  • New dual-backend test tracing-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)
  • Visual check of the new metadata UI (sidebar, list filters, cost dashboard toggle) in a browser — Chrome extension wasn't connected during this session

🤖 Generated with Claude Code

https://claude.ai/code/session_01R7LsJcWXZ2D9ZmhEWx1UVL

…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
@anilguleroglu
anilguleroglu merged commit 7a5b286 into main Aug 17, 2026
1 check passed
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.

1 participant