diff --git a/litellm/litellm_core_utils/core_helpers.py b/litellm/litellm_core_utils/core_helpers.py index cc7fab718f3..af6e0996e3a 100644 --- a/litellm/litellm_core_utils/core_helpers.py +++ b/litellm/litellm_core_utils/core_helpers.py @@ -30,13 +30,10 @@ def is_codex_user_agent(user_agent: str) -> bool: def qualify_provider_stripped_model(model: str, custom_llm_provider: str) -> str: - """ - Put the provider prefix back on a model an agentic follow-up re-dispatches with. + """Put the provider prefix back on a provider-stripped model. - Handlers are handed the provider-stripped model, and for providers that route through - a sub-path (``bedrock/mantle/...``, ``openrouter/openai/...``) that remainder still - holds a slash. Treating any slash as "already qualified" drops the prefix and leaves a - string no provider can be resolved from. + A sub-path provider (``bedrock/mantle/...``) leaves a slash in the remainder, so + treating any slash as "already qualified" would drop the prefix. """ if not custom_llm_provider or model.startswith(f"{custom_llm_provider}/"): return model diff --git a/tests/test_litellm/litellm_core_utils/test_core_helpers.py b/tests/test_litellm/litellm_core_utils/test_core_helpers.py index b1575cadc26..cd834beff92 100644 --- a/tests/test_litellm/litellm_core_utils/test_core_helpers.py +++ b/tests/test_litellm/litellm_core_utils/test_core_helpers.py @@ -418,12 +418,9 @@ class TestQualifyProviderStrippedModel: @pytest.mark.parametrize( "model,provider,expected", [ - # the reported case: bedrock's OpenAI-compatible sub-path ("mantle/anthropic.claude-sonnet-5", "bedrock", "bedrock/mantle/anthropic.claude-sonnet-5"), ("invoke/anthropic.claude-v2", "bedrock", "bedrock/invoke/anthropic.claude-v2"), - # another provider whose stripped model keeps a slash ("openai/gpt-4o", "openrouter", "openrouter/openai/gpt-4o"), - # the ordinary case still works ("gpt-4o", "openai", "openai/gpt-4o"), ("claude-sonnet-4-5", "anthropic", "anthropic/claude-sonnet-4-5"), ],