← Back to PRs

#9905: fix: require provider prefix for models set without alias (#5790)

by petter-b open 2026-02-05 21:16 View on GitHub →
commands agents stale size: S trusted-contributor
Root cause: `models set` defaulted to `anthropic/` provider when no prefix was given, causing local models like `qwen2.5-coder:7b` to be stored as `anthropic/qwen2.5-coder:7b`. Fix: Reject models without provider prefix unless they match a known alias; clear error message guides users to use `provider/model` format. Test: Added tests for rejection case, explicit prefix case, and alias bypass case. Fixes #5790 <!-- greptile_comment --> <h3>Greptile Summary</h3> This PR fixes issue #5790 where `models set` (and other model commands) would silently default to the `anthropic/` provider when no provider prefix was given. This caused local models like `qwen2.5-coder:7b` to be incorrectly stored as `anthropic/qwen2.5-coder:7b`. - `resolveModelTarget` in `src/commands/models/shared.ts` now rejects model strings without a `/` provider prefix unless they match a known user-configured alias, throwing a clear error message guiding users to use `provider/model` format - The fix applies consistently across all model commands (`set`, `set-image`, `fallbacks add/remove`, `image-fallbacks add/remove`, `aliases set`) since they all use `resolveModelTarget` - Three new tests in `models.set.e2e.test.ts` cover the rejection case, explicit prefix case, and alias bypass case - A new test in `model-fallback.e2e.test.ts` documents that the fallback loop respects user-configured providers and does not inject `anthropic` into the candidate list The implementation is clean — the guard check is correctly placed after alias resolution but before returning, and uses the existing `resolved.alias` field to determine whether the input matched an alias. No issues found. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge — it's a focused input validation fix with comprehensive test coverage and no regressions. - The change is a well-scoped guard clause in a single function (`resolveModelTarget`) that adds input validation rather than changing core logic. The fix correctly uses existing data (`resolved.alias`) from the model resolution pipeline. All three key scenarios (rejection, explicit prefix, alias bypass) are tested. The function is used by 6 command files, all of which benefit from this validation consistently. The fallback test provides additional confidence that the broader system respects user-configured providers. No edge cases were found that could cause regressions. - No files require special attention. <sub>Last reviewed commit: e04381a</sub> <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs