fix: strip provider_specific_fields from Anthropic count_tokens - #5757
Open
atharvamhaske wants to merge 1 commit into
Open
fix: strip provider_specific_fields from Anthropic count_tokens#5757atharvamhaske wants to merge 1 commit into
atharvamhaske wants to merge 1 commit into
Conversation
Contributor
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe change sanitizes Anthropic count-token content blocks by removing ChangesAnthropic count-token request handling
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested reviewers: 🚥 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 |
atharvamhaske
force-pushed
the
count-tokens
branch
from
August 1, 2026 06:20
1193506 to
7b9fbc1
Compare
Claude Code history includes a non-spec field that strict count_tokens backends (e.g. vLLM) reject; enable IsCountTokens cleanup for vLLM.
atharvamhaske
force-pushed
the
count-tokens
branch
from
August 1, 2026 06:21
7b9fbc1 to
103b80c
Compare
atharvamhaske
marked this pull request as ready for review
August 1, 2026 06:22
coderabbitai
Bot
requested review from
Pratham-Mishra04,
TejasGhatte and
akshaydeo
August 1, 2026 06:23
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
Claude Code CLI serializes
tool_usehistory with"provider_specific_fields": null. Bifrost's Anthropic/v1/messages/count_tokenspath was forwarding that non-spec field to strict Anthropic-compatible backends (notably vLLM), which reject it withExtra inputs are not permittedand break Claude Code sessions after the first tool use./v1/messagesoften still succeeded because that path is more lenient or converts the payload differently.Changes
StripProviderSpecificFieldsFromContentBlocksto removeprovider_specific_fieldsfrommessages[].content[]BuildAnthropicResponsesRequestBodywhenIsCountTokensis true (alongside existingfallback_credit_tokenstripping)IsCountTokens: trueand passModelinVLLMProvider.CountTokensso the count_tokens cleanup path actually runs for vLLMtool_usehistory on the raw-body count_tokens pathType of change
Affected areas
How to test
Manual curl against Bifrost → vLLM:
Screenshots/Recordings
N/A
Breaking changes
Related issues
Related to Claude Code + OpenAI-compatible / vLLM Anthropic compatibility (e.g. #2826).
Closes : #5684
Security considerations
None. Only strips a non-spec client field from count_tokens request bodies before upstream forwarding.
Checklist
docs/contributing/README.mdand followed the guidelines