Repository navigation
fix(providers): map gateway model ids before cloud fallback - #118
Closed
cursor[bot] wants to merge 1 commit into
Closed
cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
config.example.toml sets agent.model to anthropic/claude-sonnet-4-20250514. Both cloud backends forwarded that string. Anthropic rejects the vendor prefix with HTTP 4xx, which stops the fallback chain before local. OpenAI receives the same Claude id after an Anthropic 5xx and returns HTTP 400, which also stops the chain. Strip a matching vendor prefix and skip a foreign cloud id with a non-HTTP error so the router can continue. Co-authored-by: esadrianno <esadrianno@gmail.com>
This was referenced Oct 16, 2026
Collaborator
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.
Bug and impact
Copying
config.example.tomland settingANTHROPIC_API_KEYmakes every chat fail.agent.modelisanthropic/claude-sonnet-4-20250514. The Anthropic Messages API expects the id without theanthropic/prefix and rejects the example value with HTTP 4xx. The router treats 4xx as terminal, so the local llama-server backend is never tried.If Anthropic is down (5xx) and
OPENAI_API_KEYis also set, OpenAI is called with the same Claude id, returns HTTP 400, and local is still skipped.Root cause
anthropic.candopenai.csendconfig_agent_model()verbatim. The built-ingpt-4o-mini/claude-3-5-sonnet-20241022defaults apply only when that string is missing, whichconfig_loaddoes not allow. A 4xx anywhere in the provider error stopsfallback_chain.Fix
provider_model_id_for_backend()strips a matchingvendor/prefix (anthropic/claude-sonnet-4-20250514becomesclaude-sonnet-4-20250514on Anthropic,openai/gpt-4obecomesgpt-4oon OpenAI). A known foreign cloud id is skipped with an error that does not containHTTP 4xx, so the router continues to the next backend. Unknown names such as the local Phi-3 id are left unchanged.Validation
make test_provider test_anthropic test_openaipassed. The Anthropic test records the request model with HTTP skipped and expectsclaude-sonnet-4-20250514. The OpenAI test uses the example model and a dummy key and expects an immediate retryable skip with no network call.