Repository navigation
fix(anthropic): preserve reported thinking token usage - #6721
Merged
Merged
Conversation
Map the upstream reasoning subset without changing inclusive output totals. Cover final cumulative SSE usage and buffered/streamed Chat and Responses projections. Co-authored-by: daehwanahn <31888220+daehwanahn@users.noreply.github.com>
Contributor
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (6)
✨ 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 |
Contributor
|
✅ Deterministic PR hygiene checks passed. |
2 tasks done
lidge-jun
marked this pull request as ready for review
October 8, 2026 01:17
3 tasks done
lidge-jun
added a commit
that referenced
this pull request
Oct 8, 2026
This was referenced Oct 8, 2026
Merged
lidge-jun
added a commit
that referenced
this pull request
Oct 8, 2026
…atchet (#6733) #6721 and #6724 each added one explicit registration and together took scripts/test-layout/layout.json to 2000 lines, over the 1999-line NEW_OVERSIZED ratchet, so file-size ratchet: repository fails on dev and on every PR's merge ref. Fold forty single-entry lines into four-per-line rows (the file's existing compact form). The parsed mapping is unchanged; the file drops to 1970 lines.
2 of 7 tasks
3 tasks done
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
usage.output_tokens_details.thinking_tokensasOcxUsage.reasoningOutputTokens, so translated Responses and Chat JSON/SSE replies expose the realreasoning_tokensbreakdown.output_tokens: output totals, cache accounting and spend totals are unchanged. No estimate is made from visible/summarized thinking. Missing, malformed, negative, nonfinite or above-total optional detail stays unreported internally without discarding valid totals.message_deltadetail; no stream/retry/authentication behavior is changed. Cover buffered, chunked SSE, terminal-without-message_stop, incomplete/error usage and both downstream encoders. Native Messages passthrough is unchanged.Verification
Exact head
e0f539ace1d5c3c5e054501b2eca3e0367470fe4, based on trusted devbbab02ab270e30219dea97fea07471e776d65479; ubuntu, Linux x64, Bun 1.4.0 (34cbb9a40).bun scripts/test.ts --parallel=1 tests/adapters/anthropic/anthropic-thinking-usage.test.ts tests/adapters/anthropic/anthropic-error-stop-reason.test.ts tests/adapters/anthropic/anthropic-compatible-stream.test.ts tests/adapters/anthropic/anthropic-reasoning.test.ts tests/test-layout.test.ts tests/test-layout-tooling.test.ts tests/ci-workflows/file-size-ratchet.test.ts --timeout 20000— 150 pass / 0 fail, 1035 assertions, 7 files. The new 18 cases include real adapter parsers and JSON/SSE Responses-to-Chat projections.bun scripts/structure-ssot.ts— passed.git diff --check— passed. New test registered in both layout inventories; no baseline increase.bun node_modules/typescript/bin/tsc --noEmit— incomplete: the cgroup's 180-second RuntimeMax stopped it; no typecheck success is claimed. No limit increase or retry.Checklist
No authentication, credential, provider destination or permission policy is changed. The unchecked box does not claim a scan/sign-off. This PR remains Draft because local typecheck is incomplete, docs build and broader validation are outstanding, and required exact-head CI/independent review must still complete. No merge/release is requested by this PR creation.