Skip to content

Comments

fix(proxy): don't replace response model with alias#21874

Open
navalprakhar wants to merge 4 commits intoBerriAI:mainfrom
navalprakhar:fix/21665-proxy-model-alias-regression
Open

fix(proxy): don't replace response model with alias#21874
navalprakhar wants to merge 4 commits intoBerriAI:mainfrom
navalprakhar:fix/21665-proxy-model-alias-regression

Conversation

@navalprakhar
Copy link

@navalprakhar navalprakhar commented Feb 22, 2026

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 replacing response.model with 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

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Type

🐛 Bug Fix

Changes

Instead of replacing response.model with the client alias, now we just strip known provider prefixes (using LlmProvidersSet). Same fix in both non-streaming and streaming paths. Also cleaned up _get_client_requested_model_for_streaming() and _litellm_client_requested_model since they're dead code now.

@vercel
Copy link

vercel bot commented Feb 22, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 22, 2026 4:20am

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 22, 2026

Greptile Summary

Fixes #21665 — the proxy was replacing response.model with the client-requested alias (e.g. "default") instead of preserving the actual model name (e.g. "global.anthropic.claude-sonnet-4-5-20250929-v1:0"). This was introduced in #19943 which intended to strip internal provider prefixes like hosted_vllm/ but went too far by overriding with the client alias in all cases.

  • _override_openai_response_model now only strips known LlmProvidersSet prefixes (e.g. hosted_vllm/, bedrock/) from the response model field, preserving the real model name
  • Same fix applied to _restamp_streaming_chunk_model for streaming chunks
  • Removed dead code: _get_client_requested_model_for_streaming(), _litellm_client_requested_model plumbing, and fallback-specific handling (no longer needed since the actual model name is always preserved)
  • Tests rewritten to cover prefix-stripping behavior plus a new regression test verifying the actual model name is returned instead of the alias

Confidence Score: 5/5

  • This PR is safe to merge — it's a targeted, well-tested fix that simplifies the response model handling while correctly fixing the reported regression.
  • The change is narrowly scoped to response model field handling. The new prefix-stripping logic is straightforward and well-guarded (checks for known providers only). All removed code paths have no remaining callers. Tests cover the key scenarios including the regression case from [Bug]: Newer LiteLLM Proxy returns model alias instead of name #21665, nested slashes, unknown prefixes, and both dict and object response types. The approach of only stripping known provider prefixes is safer than the previous approach of overriding with the client alias.
  • No files require special attention

Important Files Changed

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
Loading

Last reviewed commit: 9234a0a

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 22, 2026

Additional Comments (1)

tests/test_litellm/proxy/test_response_model_sanitization.py
Dead code and stale docstring in test

The test still passes _litellm_client_requested_model in request_data (line 203), but this key is no longer read by any production code — it was removed in this PR. The docstring (lines 169-173) also still describes the old alias-mapping behavior. Consider cleaning both up so the test accurately documents the current behavior.

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!

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

@navalprakhar
Copy link
Author

@greptileai

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Newer LiteLLM Proxy returns model alias instead of name

1 participant