Session usage undercounted delegation because Claude Code stores each subagent in a separate transcript. Include descendant subagents by default across local, server, PostgreSQL, and DuckDB views while keeping aggregate reports unchanged. The --own-only flag preserves the previous per-transcript view.
Also account for billed Claude web searches and restore the deprecated cost_usd compatibility field so supported backends report consistent costs.
- fix(usage): preserve complete session costs
- fix(usage): retain output beyond cost rows
- fix(usage): include delegated forks
- docs(usage): correct 1-based breakdown ordinals in session API
- fix(usage): refresh S3 subagent transcripts on demand
- fix(usage): preserve S3 subagent namespaces
- fix(usage): preserve S3 subagent projects
- fix(usage): count complete streaming snapshots
- fix(usage): align session totals with streaming snapshots
- fix(usage): refresh daemon subagent sessions
- fix(usage): harden subagent aggregation
- fix(usage): mark incomplete subagent costs
- fix(usage): require row coverage for complete costs
- fix(usage): ignore empty rows for cost coverage
- fix(usage): allow explicit zero token metadata
- fix(usage): prefer complete cross-session snapshots
- fix: stabilize snapshot attribution and scheduler retries
- fix(usage): preserve attributed snapshot metadata
- test(duckdb): pin the prior mirror boundary
- docs: design remote usage compatibility safeguards
- docs: plan remote usage compatibility fixes
- fix(usage): reject incompatible remote rollups
- fix(embeddings): renew periodic backstop retries
- chore: remove implementation planning artifacts
- fix(usage): preserve snapshot source accounting
- fix(usage): attribute breakdowns to source sessions
Co-authored-by: Wes McKinney <wesmckinn+git@gmail.com>
Session usage undercounted delegation because Claude Code stores each subagent in a separate transcript.
session usagenow includes descendant subagents by default across local, daemon, PostgreSQL, and DuckDB paths, while--own-onlypreserves the previous per-transcript view. Delegated forks count when they are inside the subagent subtree; root-level forks remain excluded.Targeted refresh keeps daemon reads fresh without making the usage GET endpoint state-changing. Local and S3-backed parents synchronize through the protected refresh path before the CLI fetches combined usage, preserving remote namespaces and project attribution even when the configured root has been removed.
Explicit remote combined usage now requires daemon API v5. The CLI validates
/api/v1/versionbefore synchronization or usage retrieval and reports a clear upgrade-or---own-onlyerror for older daemons; own-only queries retain their earlier compatibility.Claude streaming rows are deduplicated globally by message/request identity. Reports keep the greatest output snapshot, attribute it to the earliest transcript, and settle equal snapshots deterministically across SQLite, PostgreSQL, and DuckDB. This prevents partial parent rows from displacing complete child rows while keeping per-session and automated/interactive attribution stable.
Billed Claude server-side web searches are priced on top of tokens across session, daily, and activity reports. The parser uses the linked WebSearch result when the message counter is absent; side-call tokens that Claude Code does not persist remain a documented undercount. Combined costs are exposed only when every included token-bearing session has contributing usage coverage, and the deprecated
cost_usdfield uses the same shared conversion on every backend.The daemon embedding scheduler coalesces periodic ticks during an active bounded retry. Exhaustion releases the retained idle lease, while a later periodic tick or real mutation starts a fresh bounded reconciliation lifecycle.
Reviewers should focus on
internal/service/session_usage_subagents.go, the remote guard incmd/agentsview/session_usage.go, shared survivor selection ininternal/activity/activity.go, snapshot ranking in each usage backend, S3 hydration ininternal/sync/s3_source.go, and the retry lifecycle incmd/agentsview/embed_scheduler.go.