Skip to content

Ingest Claude Code sub-agent sessions; fix model filter on MCP views#4

Merged
JedIV merged 1 commit into
JedIV:mainfrom
ludwigehlert-gif:fix/subagents-and-mcp-model-filter
May 20, 2026
Merged

Ingest Claude Code sub-agent sessions; fix model filter on MCP views#4
JedIV merged 1 commit into
JedIV:mainfrom
ludwigehlert-gif:fix/subagents-and-mcp-model-filter

Conversation

@ludwigehlert-gif
Copy link
Copy Markdown
Contributor

Summary

  • Sub-agent sessions are now ingested. Claude Code writes Task-tool sub-agent transcripts to ~/.claude/projects/<project>/<sessionId>/subagents/agent-*.jsonl. discover_files() only globbed */*.jsonl, so those files were never seen and their token usage (often claude-haiku-4-5) was invisible in totals, charts, and breakdowns. The parser now picks them up and rolls them into the parent session.
  • /api/mcp now accepts the model query param. It was missing from the function signature, so the model filter was silently dropped on the "by mcp server" and "by mcp tool" breakdowns.
  • MCP views now filter model per-message, not per-session. Both /api/mcp and the MCP branch of /api/breakdown_series filter via the assistant turn that issued the call (mcp_calls.source_file+source_linemessages.source_file+source_line), matching how /api/stats filters. Previously breakdown_series filtered on sessions.model, which is the session's last-observed model and wrong when a session mixes models (e.g. parent Opus + sub-agent Haiku).

Test plan

  • uv run python -m tracker.ingest -v — new files under */subagents/ are picked up; message counts increase.
  • In the UI, switch to "by mcp server" or "by mcp tool" and apply a model filter — totals change accordingly.
  • Open a session that spawned sub-agents — sub-agent turns appear in the timeline on their own model rows.

🤖 Generated with Claude Code

Sub-agent (Task tool) turns are written to
~/.claude/projects/<project>/<sessionId>/subagents/agent-*.jsonl and were
never discovered by the ingester, so usage from spawned agents (often
claude-haiku-4-5) was invisible in totals, charts, and breakdowns. The
parser now globs those files and rolls their messages into the parent
session.

The /api/mcp endpoint was missing the `model` query parameter entirely,
so the model filter was silently dropped on the "by mcp server" and
"by mcp tool" breakdowns. /api/breakdown_series did accept it but
filtered on sessions.model (last observed), which is wrong when a
session uses multiple models. Both now filter per-message via the
assistant turn that issued the call (matching mcp_calls.source_file +
source_line to messages.source_file + source_line), consistent with
how /api/stats already filters.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@JedIV JedIV merged commit 7da2490 into JedIV:main May 20, 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.

2 participants