Ingest Claude Code sub-agent sessions; fix model filter on MCP views#4
Merged
JedIV merged 1 commit intoMay 20, 2026
Merged
Conversation
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
approved these changes
May 20, 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.
Summary
~/.claude/projects/<project>/<sessionId>/subagents/agent-*.jsonl.discover_files()only globbed*/*.jsonl, so those files were never seen and their token usage (oftenclaude-haiku-4-5) was invisible in totals, charts, and breakdowns. The parser now picks them up and rolls them into the parent session./api/mcpnow accepts themodelquery 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.modelper-message, not per-session. Both/api/mcpand the MCP branch of/api/breakdown_seriesfilter via the assistant turn that issued the call (mcp_calls.source_file+source_line↔messages.source_file+source_line), matching how/api/statsfilters. Previouslybreakdown_seriesfiltered onsessions.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.🤖 Generated with Claude Code