Repository navigation
fix(anthropic): gate sampling params on /v1/messages by supports_sampling_params - #35059
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
|
Greptile SummaryThe PR aligns Anthropic
Confidence Score: 5/5The PR appears safe to merge with no actionable defects identified. The messages path now delegates sampling parameters to the same established capability check used by Anthropic chat handling, and the added tests exercise the significant success and rejection branches.
|
| Filename | Overview |
|---|---|
| litellm/llms/anthropic/experimental_pass_through/messages/utils.py | Reuses the existing Anthropic sampling-capability logic on the messages path without introducing a concrete behavioral regression. |
| tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_request_optional_param_utils.py | Adds focused regression tests covering all three sampling parameters and the relevant supported, dropped, rejected, and exception paths. |
Reviews (1): Last reviewed commit: "fix(anthropic): gate sampling params on ..." | Re-trigger Greptile
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
TLDR
Problem this solves:
/v1/messagessent temperature/top_p/top_k to models that reject themHow it solves it:
/v1/messagesnow runs the samesupports_sampling_paramsgating as chatRelevant issues
Fixes #35053
Linear ticket
Pre-Submission checklist
@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Live proxy against the real Anthropic API,
drop_params: true, modelanthropic/claude-opus-4-8Before, at c274cf3 (parent commit, fix reverted):
After, at 371e436:
Type
🐛 Bug Fix
Changes
AnthropicMessagesRequestUtils.get_requested_anthropic_messages_optional_paramonly ran_maybe_drop_speed_paramagainst the model, sotemperature,top_pandtop_kreached models whose map entry hassupports_sampling_params: false(opus-4-7, opus-4-8, opus-5, fable/sonnet-5 generation) and the provider 400'd, while/chat/completionsdropped them viaAnthropicModelInfo._apply_sampling_param. The nastier symptom is that router fallbacks convert that 400 into a 200 served by an older model generation, so callers silently lose the model they asked forThe same helper now runs on the
/v1/messagespath:so behavior matches chat completions exactly: keep the param when the model supports sampling (or
temperature=1), drop it underdrop_params, otherwise raise a clean client-sideUnsupportedParamsErrorinstead of a provider 400Final Attestation
Link to Devin session: https://app.devin.ai/sessions/29adb4546877457cbf6432ca2714de8c