You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GET /api/agents/usage-by-agent now rolls up subagent token usage — claude-usage-service.ts walks <projectDir>/<sessionId>/subagents/**/agent-*.jsonl in addition to the parent session JSONL, summing both Task/Agent tool spawns and Workflow-tool fan-out runs into each agent's totals. Previously the endpoint reported only the parent-session tokens, which understated cost for boss agents and any agent running multi-agent workflows.
Added
ClaudeUsageByAgentEntry now exposes subagentTokens: ClaudeTokenTotals and subagentRequestCount: number alongside the existing tokens field (which is now the rolled-up total).
Technical Details
New collectSubagentJsonlPaths recursively walks the subagents tree, covering both Task/Agent spawns (flat under subagents/) and Workflow-tool runs (nested under subagents/workflows/<runId>/).
scanSessionUsage was split into createAccumulator + scanFileIntoAccumulator so the parent and subagent files can flow into separate accumulators that are merged in the entry.
An mtime fast-path in scanFileIntoAccumulator skips files whose mtimeMs < since so windowed queries don't pay for cold history.
Client type in src/packages/client/api/claude-usage.ts mirrored. StatisticsModal already reads entry.tokens.total, so the chart reflects the new totals without UI changes.
Verified live against the running TC instance: Oddy Taylor (mid-workflow) now shows 53.2M tokens (was ~10.4M parent-only), with 42.8M attributed to 592 subagent requests.