fix: generalize local-model validation bypass beyond Ollama tags#3271
fix: generalize local-model validation bypass beyond Ollama tags#3271Aneesh-382005 wants to merge 1 commit into
Conversation
|
Good fix — the restriction that only Ollama-style tags (with . or :) could bypass validation was a real pain point for LM Studio/llama.cpp users with bare model names. Reusing the existing is_local_openai_compatible_base_url check to also waive the model-name shape constraint is the right approach — it's scoped to loopback/private URLs, so remote gateways keep validation. The anti-slop triage section with the concrete reproducer is appreciated. |
Thanks for the review! Once this merges, I'm planning a couple of follow-up PRs for named per-backend environment variables and a config-based local provider registry. Do you think it's better to wait for this to merge before opening those, or would it be fine to work on them in parallel? |
Summary
is_local_openai_model_syntax()only bypassed strictprovider/modelvalidation when the model name contained a.or:(Ollama-tag-shaped). Bare names LM Studio/llama.cpp commonly use (e.g.mistral) were rejected unless prefixed withlocal/.is_local_openai_compatible_base_url()check (already used to waive the API-key requirement) to also waive the model-name shape check whenOPENAI_BASE_URLis loopback/private. Remote gateways keep the old heuristic, so a mistyped bare name can't silently route to a paid API.Anti-slop triage
OPENAI_BASE_URL=http://127.0.0.1:1234/v1 claw --model "mistral" prompt "hi"fails today withinvalid model syntaxdespite the server serving that model. Verified fixed against a local mock server; verified remote gateways (openrouter.ai) still reject bare names.Verification
scripts/fmt.sh --check,cargo test --workspaceall pass, incl. 4 new tests.git diff --checkpasses.cargo clippy --workspace -- -D warningsfails, but identically on unmodifiedmain(confirmed viagit stash) -> pre-existing, not touched by this PR.Resolution gate
OLLAMA_HOSTsupport); ROADMAP entry added.Future plans
Deferring two follow-ups raised in #3213's review to separate PRs: named per-backend env vars (
LMSTUDIO_HOST, etc.) and a config-based local-provider registry. Keeping this one small and reviewable.