fix(parser): preserve Claude reasoning usage without double billing - #590
fix(parser): preserve Claude reasoning usage without double billing#590Kooooojun wants to merge 1 commit into
Conversation
|
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 (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughClaude usage normalization now separates reasoning tokens from output tokens, caps reasoning at total output, and preserves total token and cost calculations. Tests cover varied usage details and confirm idempotent incremental parsing. ChangesClaude reasoning usage
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Claude session parsing now preserves reasoning-token usage while keeping total token counts and cost stable. The covered parsing and billing behaviors are ready to merge. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Full-suite baseline comparison completed with the same installed dependencies: unmodified base 3367ddd has 2,632 passed / 14 failed / 7 skipped (2,653 total); patched run has 2,633 passed / 14 failed / 7 skipped (2,654 total). The sets of failing test names match exactly; no newly failing tests observed. Final focused run (including 10 numeric fixture variants) passes all 17 tests. Self-review checked token/cost conservation, explicit-zero precedence, malformed values, and incremental idempotency. Maintainer review is pending; no service was changed. |
Summary
Preserve reported reasoning usage from Claude Code / Anthropic-compatible session records instead of always storing zero.
output_tokens_details.thinking_tokens, falling back toreasoning_tokenswhen absent (not when explicitly zero).output_tokens: Claude rows price reasoning separately, so simply adding the detail would double bill it. Keep total tokens and cost unchanged.Validation
validate:guardrails,validate:versions,git diff --checkpass.npm testis not green locally: Copilot SQLite-sidecar and sync-store tests failed (unmodified areas); full results will be appended when the run finishes. Initial run before installing dependencies also failed on missing packages; that is not claimed as validation.Scope / limitations
No conversation content or credentials included. No release, version bump, deployment, or local service changes; release coordination belongs to the maintainer.
This fixes newly parsed queue usage, not historical backfill, session discovery, or context-category estimation. Existing logs with the detail omitted cannot reconstruct it. Upstream proxies must preserve the field first: router-for-me/CLIProxyAPI#5587.
Summary by CodeRabbit