Repository navigation
Fix #107: Use configured tier model on Ollama/custom endpoints instead of Claude ID - #328
zwanski-start wants to merge 1 commit into
Conversation
… endpoints
The UI/stored model (e.g. claude-opus-4-7) was passed verbatim via --model.
The Claude CLI only applies ANTHROPIC_DEFAULT_{OPUS,SONNET,HAIKU}_MODEL to
tier aliases, so Ollama and other custom endpoints received a Claude model
ID they don't serve (404 model not found). When ANTHROPIC_BASE_URL is set
(non-Vertex), resolve a claude-* model to the matching tier override.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🔍 QA report: ✅ PassedTester: Ken (cubefarm agent, in a fresh session) · Round: 1 · Author: Dennis The fix works: with Ollama set up through .env (ANTHROPIC_BASE_URL plus tier overrides), a stored Claude model ID such as claude-opus-4-5-20251101, or a Sonnet pick, is now replaced with the matching ANTHROPIC_DEFAULT_*_MODEL. Before, it was sent as is and got a 404. A side-by-side check of create_client confirms master sends the Claude ID and this branch sends qwen2.5-coder. Plain Anthropic, Vertex and Settings-UI providers are unchanged. Lint, tests, the UI build and a server smoke test show no regressions; the remaining test and mypy failures are the same on master.
🧪 Commands run
No browser screenshots were taken in this round. Posted by cubefarm · merges automatically once GitHub's checks pass |
Closes #107
Problem
With Ollama (or any custom
ANTHROPIC_BASE_URL) configured via.env, the agent still requestedclaude-opus-4-5-20251101and got a 404. The model passed to the CLI comes from the stored UI setting (api_modelormodel, falling back toDEFAULT_MODEL). That value is a full Claude ID. The Claude CLI appliesANTHROPIC_DEFAULT_{OPUS,SONNET,HAIKU}_MODELonly to the tier aliases (opus/sonnet/haiku), not to explicit IDs, so the Claude ID went straight to Ollama. Switching to Sonnet in the UI hit the same problem.Fix
client.py: newresolve_model_for_endpoint(model, sdk_env). WhenANTHROPIC_BASE_URLis set (and Vertex is off) and the model is aclaude-*ID, it is replaced with the matching tier override (opus →ANTHROPIC_DEFAULT_OPUS_MODEL, sonnet →..._SONNET_..., haiku →..._HAIKU_...). Non-Claude model names, missing or blank overrides, Vertex, and the plain Anthropic API are left alone. It's applied increate_client, the single point where the model reaches the SDK, so the single-agent, parallel, testing and scheduled paths are all covered.Verification
TestResolveModelForEndpoint(9 cases) totest_client.py:venv/bin/python -m pytest test_client.pypasses (30 tests).ruff check .is clean andpython test_security.pypasses.mypy client.pyreports only a pre-existing unused-ignore on theeffort=line (it depends on the local SDK version and is unrelated).Assumptions
api_modeland set all three overrides, so this only changes behavior for.env-configured endpoints, or when a Claude ID still reaches a custom endpoint.🤖 Generated with Claude Code