fix: avoid sending both temperature and top_p to Anthropic API#4471
Merged
whysosaket merged 2 commits intomainfrom Mar 23, 2026
Merged
fix: avoid sending both temperature and top_p to Anthropic API#4471whysosaket merged 2 commits intomainfrom
whysosaket merged 2 commits intomainfrom
Conversation
Anthropic rejects requests with both temperature and top_p set. Default top_p to None in AnthropicConfig and override _get_common_params to prefer temperature when both are present. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
18 tasks
Member
|
Tests are failing |
whysosaket
reviewed
Mar 21, 2026
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Author
|
@themavik Thanks for the quick review! It's called indirectly through the inheritance chain. |
whysosaket
approved these changes
Mar 23, 2026
jamebobob
pushed a commit
to jamebobob/mem0-vigil-recall
that referenced
this pull request
Mar 29, 2026
…i#4471) Co-authored-by: utkarsh240799 <utkarsh240799@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.
Description
Anthropic's API rejects requests that include both
temperatureandtop_pwith:This PR fixes the default Anthropic LLM configuration so it works out of the box:
top_ptoNoneinAnthropicConfiginstead of0.1, so it is not sent alongsidetemperature_get_common_params()inAnthropicLLMto prefertemperatureand droptop_pwhen both are set (handles theBaseLlmConfigconversion path wheretop_p=0.1is inherited)The fix is scoped entirely to the Anthropic provider — no other providers are affected.
Type of change
How Has This Been Tested?
Added
tests/llms/test_anthropic.pywith 5 test cases:test_default_config_omits_top_pAnthropicConfig()defaultstop_ptoNonetest_generate_response_does_not_send_top_p_by_defaulttemperature, nottop_ptest_generate_response_sends_top_p_alone_when_no_temperaturetop_pis set (temperature=None),top_pis senttest_both_set_prefers_temperature_over_top_ptemperaturewins andtop_pis droppedtest_base_config_conversion_does_not_send_bothBaseLlmConfig(which defaults both) converted toAnthropicConfigdoes not send bothpytest tests/llms/test_anthropic.py -v # 5 passedChecklist:
Maintainer Checklist
🤖 Generated with Claude Code