Skip to content

fix: generalize local-model validation bypass beyond Ollama tags#3271

Open
Aneesh-382005 wants to merge 1 commit into
ultraworkers:mainfrom
Aneesh-382005:fix/local-model-validation-bypass
Open

fix: generalize local-model validation bypass beyond Ollama tags#3271
Aneesh-382005 wants to merge 1 commit into
ultraworkers:mainfrom
Aneesh-382005:fix/local-model-validation-bypass

Conversation

@Aneesh-382005

Copy link
Copy Markdown

Summary

  • is_local_openai_model_syntax() only bypassed strict provider/model validation 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 with local/.
  • Fix: reuse the existing is_local_openai_compatible_base_url() check (already used to waive the API-key requirement) to also waive the model-name shape check when OPENAI_BASE_URL is loopback/private. Remote gateways keep the old heuristic, so a mistyped bare name can't silently route to a paid API.
  • Scoped narrowly on purpose see Future plans.

Anti-slop triage

  • Classification: actionable-fix
  • Evidence: OPENAI_BASE_URL=http://127.0.0.1:1234/v1 claw --model "mistral" prompt "hi" fails today with invalid model syntax despite the server serving that model. Verified fixed against a local mock server; verified remote gateways (openrouter.ai) still reject bare names.
  • Non-destructive review result: merge candidate

Verification

  • scripts/fmt.sh --check, cargo test --workspace all pass, incl. 4 new tests.
  • git diff --check passes.
  • No secrets/unrelated churn; diff scoped to 6 files.
  • Note: cargo clippy --workspace -- -D warnings fails, but identically on unmodified main (confirmed via git stash) -> pre-existing, not touched by this PR.

Resolution gate

  • Follow-up to my earlier PR Feat/ollama provider #3213 (native OLLAMA_HOST support); ROADMAP entry added.
  • N/A - intended to merge.
  • N/A - no remote PR/issue automation actions taken.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant