fix: forward max_completion_tokens to Anthropic native provider#5014
Open
khan5v wants to merge 1 commit intocrewAIInc:mainfrom
Open
fix: forward max_completion_tokens to Anthropic native provider#5014khan5v wants to merge 1 commit intocrewAIInc:mainfrom
khan5v wants to merge 1 commit intocrewAIInc:mainfrom
Conversation
The AnthropicCompletion class did not accept max_completion_tokens, causing it to silently fall into **kwargs and get ignored. Users setting max_completion_tokens (the OpenAI-style parameter name) on an Anthropic model always got the default 4096 max_tokens instead. Add max_completion_tokens as an explicit parameter with the same fallback chain used by the LiteLLM path: max_tokens wins, then max_completion_tokens, then the 4096 default.
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
max_completion_tokens(OpenAI-style parameter) is silently ignored by the native Anthropic provider**kwargs->additional_paramsand never reachesself.max_tokensllm.py:717), but the native path does notcompletion.py:203)Fix
Accept
max_completion_tokensinAnthropicCompletion.__init__with the same fallback chain:max_tokens->max_completion_tokens->4096Test plan
max_completion_tokens=150flows through to_prepare_completion_paramsasmax_tokens: 150max_tokenstakes precedence when both are set