fix(server): include Claude advisor calls in usage totals - #10488
LukasWallrich wants to merge 2 commits into
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This focused fix corrects Claude usage totals by parsing advisor records through the existing aggregation and pricing pipeline, with cache invalidation and substantial regression coverage. Its runtime impact is confined to usage reporting and the expected one-time re-scan of stale cached transcripts. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe Claude transcript parser now emits separate executor and advisor usage records. The transcript reader handles multiple records per line. Cache version 4 re-parses existing Claude transcripts, and tests validate deduplication and pricing. ChangesClaude usage parsing
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This updates Usage reporting to include distinct Claude advisor records alongside executor usage. No current merge-blocking risk is identified. Sequence Diagram(s)sequenceDiagram
participant TranscriptReader
participant parseClaudeLine
participant UsageAggregator
TranscriptReader->>parseClaudeLine: Parse Claude line
parseClaudeLine-->>TranscriptReader: Return executor and advisor records
TranscriptReader->>UsageAggregator: Aggregate parsed records
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
The problem
The usage dashboard provides clarity on token usage through the harnesses across interfaces. Even though T3 Code does not yet support Claude's advisor mode (see #9640), cost incurred through that in Claude Code should show up in the usage tracker here so that the numbers are accurate.
What Changed
The Usage dashboard now includes Claude advisor calls as separate usage records, priced at the advisor model's rates. Executor usage remains counted once, and advisor records use distinct keys so repeated content blocks and copied transcripts do not multiply their usage. The scan cache version is bumped to reprocess existing transcripts.
Why
Claude reports advisor sub-inferences in
usage.iterationswithtype: "advisor_message". Those tokens are excluded from top-level executor usage (Anthropic documentation). The parser previously ignored them, so advisor tokens and estimated costs were absent from the Usage dashboard.Related: #9640 explicitly leaves advisor token/cost attribution outside its scope. This change is limited to transcript-based Usage reporting.
Validation
Checklist
Written by GPT-6 in Codex. Reviewed by Claude Fable through Claude Code (
claude -p --model fable).Note
Include Claude advisor calls in usage totals via
parseClaudeLineparseClaudeLinein usageTranscripts.ts to return a read-only list of usage records instead of a single nullable record, emitting separate nonzero-token advisor records from nested iterations with distinct deduplication keysMacroscope summarized e8cb5ed.
Summary by CodeRabbit
Bug Fixes
Improvements