Repository navigation
fix(proxy): map output_config.effort to reasoning_effort for non-Anthropic providers - #25120
glaziermag wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
28bf694 to
779cc44
Compare
…ropic providers (#25079)
779cc44 to
8a0ad3e
Compare
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR fixes the missing mapping of
Confidence Score: 4/5Safe to merge after addressing the test structure inconsistency; core logic is correct and well-guarded. The implementation correctly fixes the reported issue. Prior review threads already surfaced the two main logic concerns (falsy check and silent drop of non-effort fields), and the code was updated to use an explicit Test file — new test should follow the class-based pattern used throughout the rest of the file.
|
| Filename | Overview |
|---|---|
| litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py | Adds _translate_output_config_to_openai method and wires it into translate_anthropic_to_openai; output_config added to translatable_anthropic_params to prevent blind pass-through. Logic is correct for the defined cases. |
| tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py | Adds two test cases for the new translation logic. New test is a standalone function rather than a class, inconsistent with the file's established class-based test structure; no real network calls are made. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A["translate_anthropic_to_openai()"] --> B["_translate_thinking_to_openai()"]
B --> C["_translate_output_format_to_openai()"]
C --> D["_translate_output_config_to_openai() ← NEW"]
D --> E{output_config present?}
E -- No --> I["_copy_untranslated_anthropic_params()"]
E -- Yes --> F{effort != None?}
F -- No --> I
F -- Yes --> G{is_anthropic_claude_model?}
G -- Yes --> H1["new_kwargs['output_config'] = output_config"]
G -- No --> H2{"reasoning_effort already set?"}
H2 -- Yes --> I
H2 -- No --> H3["new_kwargs['reasoning_effort'] = effort"]
H1 --> I
H3 --> I
I --> J["return new_kwargs"]
Reviews (2): Last reviewed commit: "Address PR review comments from Greptile..." | Re-trigger Greptile
| effort = output_config.get("effort") | ||
| if not effort: | ||
| return |
There was a problem hiding this comment.
Falsy check skips 0-valued effort
if not effort: will silently return early for any falsy value (empty string "", 0, None). For string effort levels this is unlikely to matter in practice, but an explicit None check is more intentional and matches how the rest of this file guards optional fields.
| effort = output_config.get("effort") | |
| if not effort: | |
| return | |
| effort = output_config.get("effort") | |
| if effort is None: | |
| return |
| model = new_kwargs.get("model", "") | ||
| if self.is_anthropic_claude_model(model): | ||
| new_kwargs["output_config"] = output_config # type: ignore |
There was a problem hiding this comment.
Silent drop of non-effort output_config fields for non-Anthropic models
For Anthropic models the whole output_config dict is forwarded (correct). But for non-Anthropic models, only effort is extracted and all other fields inside output_config (e.g. future Anthropic additions) are silently dropped. This is acceptable today since effort is the only defined field, but worth a comment so future maintainers know the intentional scope.
| model = new_kwargs.get("model", "") | |
| if self.is_anthropic_claude_model(model): | |
| new_kwargs["output_config"] = output_config # type: ignore | |
| if self.is_anthropic_claude_model(model): | |
| # Forward the full output_config dict for native Anthropic handling | |
| new_kwargs["output_config"] = output_config # type: ignore |
|
Closed by #26111 |
Fix
output_config.effortmapping for Anthropic pass-through endpoint (#25079)Expected Outcome
When a user sends a
/v1/messagesrequest to LiteLLM proxy withoutput_config: { effort: "high" }, and the model routes to an OpenAI model, theoutput_config.effortparameter should be implicitly translated to thereasoning_effort: "high"parameter for the OpenAI-compatible request.Actual Outcome & Debugging (Before vs After)
Before Logs
When testing with a straightforward proxy script routing
openai-responsemodels, the parameter was ignored andreasoning_effortwasNone.After Logs (The Fix)
The problem resided in
translate_anthropic_to_openai. By mapping the incomingoutput_configdictionary and extractingeffortforreasoning_effort, the internalChatCompletionRequestis correctly populated.Blast Radius Assessment
litellm/llms/anthropic/experimental_pass_through/adapters/transformation.pywithintranslate_anthropic_to_openai.output_configis absent, execution is unchanged.Epistemic Check
LiteLLMAnthropicMessagesAdapterlogic locally before and after the hotfix.litellm.completionnatively support overriding or processing the standardreasoning_effortkwargs as translated fromoutput_configwithout additional adapters. Given standard OpenAI mappings,reasoning_effortpropagates to target providers fine.