Skip to content

fix(core): validate model name in /model command against provider list#1445

Merged
bug-ops merged 3 commits intomainfrom
model-validation
Mar 9, 2026
Merged

fix(core): validate model name in /model command against provider list#1445
bug-ops merged 3 commits intomainfrom
model-validation

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Mar 9, 2026

Summary

  • /model <id> now validates the provided model name against the cached provider model list before applying it
  • Unknown models are rejected with an error message listing available options
  • When the model list is unavailable (cold start or provider without listing support), a warning is shown and the switch proceeds

Changes

  • crates/zeph-core/src/agent/mod.rs: validation in handle_model_command() — cache-first, remote fallback, early return on unknown model
  • crates/zeph-llm/src/mock.rs: MockProvider gains optional models field and with_models() builder for test injection
  • crates/zeph-llm/src/any.rs: AnyProvider::Mock returns injected models from list_models_remote(); doc comment updated

Test plan

  • Valid model accepted — set_model called, no error
  • Invalid model rejected — error message with available models, set_model not called
  • Empty/unavailable model list — warning shown, switch proceeds (backward compatibility)
  • cargo +nightly fmt --check clean
  • cargo clippy --workspace --features full -- -D warnings clean
  • cargo nextest run --workspace --features full --lib --bins — 4872 passed

Fixes #1417

#1417)

The /model command now checks the provided model ID against the cached
model list before applying it. Unknown models are rejected with an error
listing available options. When the model list is unavailable (cold start
or provider without listing support), a warning is shown and the switch
proceeds to preserve backward compatibility.

Fixes #1417
@github-actions github-actions bot added documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes core zeph-core crate bug Something isn't working size/M Medium PR (51-200 lines) labels Mar 9, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 9, 2026 14:26
@bug-ops bug-ops merged commit e3571f8 into main Mar 9, 2026
18 checks passed
@bug-ops bug-ops deleted the model-validation branch March 9, 2026 14:35
@bug-ops bug-ops mentioned this pull request Mar 9, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working core zeph-core crate documentation Improvements or additions to documentation llm zeph-llm crate (Ollama, Claude) rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/model command accepts any model string without validation

1 participant