fix(sdk): prevent double provider-prefix strip for namespaced model IDs - #4438
Draft
santhiprakash wants to merge 1 commit into
Draft
fix(sdk): prevent double provider-prefix strip for namespaced model IDs#4438santhiprakash wants to merge 1 commit into
santhiprakash wants to merge 1 commit into
Conversation
This was referenced Aug 9, 2026
LLMProvider.from_model() parses a model string like "openai/openai/example- model" into model="openai/example-model" + provider="openai". When as_litellm_call_kwargs() forwards that as model="openai/example-model" + custom_llm_provider="openai", LiteLLM's Responses API path re-parses and strips the "openai/" prefix again, sending "example-model" upstream instead of "openai/example-model" (400 Model not found). Re-prefix the model when it still starts with the provider prefix so LiteLLM strips exactly one prefix and lands on the parsed model. Co-Authored-By: Paperclip <noreply@paperclip.ing>
santhiprakash
force-pushed
the
fix/llm-double-prefix-strip
branch
from
August 10, 2026 10:16
ebb59ad to
f92b151
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HUMAN:
AGENT:
Why
LLMProvider.from_model()parses a model string likeopenai/openai/example-modelintomodel="openai/example-model"+provider="openai". Whenas_litellm_call_kwargs()forwards that asmodel="openai/example-model"+custom_llm_provider="openai", LiteLLM's Responses API path re-parses and strips theopenai/prefix again, sendingexample-modelupstream instead ofopenai/example-model— which returns400 Model not found.This affects any namespaced model ID where the inner segment is also a LiteLLM provider name (e.g.
openai/openai/o3-mini,mistral/mistral/large). The OpenRouter nested case (openrouter/anthropic/claude-sonnet-4) is unaffected because LiteLLM has a dedicated OpenRouter special-case that preserves the innerprovider/modelform.Summary
as_litellm_call_kwargs()when the parsed model still starts with the provider prefix, so LiteLLM strips exactly one prefix and lands on the correct parsed model.test_llm_provider_preserves_namespaced_model_after_litellm_reparsecoveringopenai/openai/example-model.Issue Number
Fixes OpenHands/OpenHands#16365
How to Test
Result (12 passed):
Pre-commit verification:
All checks passed (Ruff format, Ruff lint, PEP8, pyright, import dependency rules, tool subclass registration).
Reproduction proof (before fix vs after fix):
Video/Screenshots
N/A — backend correctness fix, no visual surface.
Type
Notes
The fix is minimal and only triggers when
self.model.startswith(f"{self.name}/")— the exact condition that causes the double-strip. All existing test cases (openrouter nested, bedrock, mistral, litellm_proxy, openai local, unknown) are unaffected because their parsed models do not start with the provider prefix.