fix(proxy): don't replace response model with alias#21874
fix(proxy): don't replace response model with alias#21874navalprakhar wants to merge 4 commits intoBerriAI:mainfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryFixes #21665 — the proxy was replacing
Confidence Score: 5/5
|
| Filename | Overview |
|---|---|
| litellm/proxy/common_request_processing.py | Core fix: _override_openai_response_model now strips known provider prefixes instead of replacing with client alias. Removed requested_model parameter, fallback-specific handling, and _litellm_client_requested_model plumbing. Logic is clean and well-guarded. |
| litellm/proxy/proxy_server.py | Streaming path updated: _restamp_streaming_chunk_model now strips provider prefixes instead of replacing with client alias. _get_client_requested_model_for_streaming and _litellm_client_requested_model plumbing fully removed. No remaining callers. |
| tests/test_litellm/proxy/test_common_request_processing.py | Tests rewritten to cover new prefix-stripping behavior: known prefix on object/dict, no-prefix passthrough, unknown prefix passthrough, and nested-slash preservation. All use the updated function signature. |
| tests/test_litellm/proxy/test_response_model_sanitization.py | Updated integration-style tests: alias mapping test now expects stripped canonical model instead of alias. New regression test for #21665 verifies actual model name is preserved. No real network calls — all mocked. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Response received from LLM provider] --> B{Is model field a string with '/'?}
B -- No --> C[Return response unchanged]
B -- Yes --> D{Is prefix in LlmProvidersSet?}
D -- No --> C
D -- Yes --> E[Strip provider prefix]
E --> F["e.g. hosted_vllm/my-model → my-model\nbedrock/claude-v2 → claude-v2\ngroq/meta-llama/llama-4 → meta-llama/llama-4"]
F --> G[Return response with stripped model]
style A fill:#e1f5fe
style C fill:#c8e6c9
style G fill:#c8e6c9
style E fill:#fff9c4
Last reviewed commit: 9234a0a
Additional Comments (1)
The test still passes Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time! |
Relevant issues
Fixes #21665
@cyberjunk you were right, it was from #19943 (ba17f51). That PR meant to strip internal provider prefixes like
hosted_vllm/from responses but also started replacingresponse.modelwith whatever the client sent (the alias) in all cases.Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewType
🐛 Bug Fix
Changes
Instead of replacing
response.modelwith the client alias, now we just strip known provider prefixes (usingLlmProvidersSet). Same fix in both non-streaming and streaming paths. Also cleaned up_get_client_requested_model_for_streaming()and_litellm_client_requested_modelsince they're dead code now.