#17469: Improve unknown-model errors for provider/model misconfiguration
agents
stale
size: XS
Cluster:
Model Configuration Fixes
## Summary
Improve diagnostics when a model references a provider prefix that isn't configured (common local proxy misconfiguration like `lmstudio/...` vs `models.providers.lmproxy`).
## What changed
- `resolveModel()` now appends actionable hints to unknown-model errors:
- Lists configured custom providers when provider is missing.
- Detects normalized provider mismatch and reports the configured key(s).
- Added test coverage in `src/agents/pi-embedded-runner/model.test.ts` for provider-hint behavior.
- Relaxed a few brittle equality assertions to `toContain` in unknown-model tests.
## Why
Today this failure mode can look like transport/network trouble ("no socket opened") even though resolution failed pre-transport. This patch makes failures immediate and obvious so users can fix config quickly.
## Example
Before:
- `Unknown model: lmstudio/minicpm-o-4_5`
After:
- `Unknown model: lmstudio/minicpm-o-4_5. Configured custom providers: "lmproxy".`
## Notes
- I couldn't run vitest in this environment because `pnpm` is not installed on this host.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Enhanced error diagnostics in `resolveModel()` to provide actionable hints when a model references an unconfigured provider prefix. The implementation correctly handles two scenarios: detecting normalized provider mismatches (e.g., requesting `lmstudio` when `lmproxy` is configured) and listing all configured custom providers when no match is found.
**Key changes:**
- Error messages now append helpful context: configured provider names or mismatch details (lines 96-113 in model.ts)
- Unit tests relaxed from `.toBe()` to `.toContain()` to accommodate variable error suffixes
- New test case validates provider hint behavior for common misconfiguration scenario
**Issues found:**
- E2e test at model.e2e.test.ts:61 still uses strict `.toBe()` assertion and will fail with the new error format that includes a trailing period
<h3>Confidence Score: 4/5</h3>
- Safe to merge after fixing the e2e test assertion
- The implementation logic is sound and well-tested, with appropriate normalization and matching. The error message construction is clear and helpful. However, the e2e test will fail due to a brittle assertion that wasn't updated alongside the unit tests, preventing a clean merge until fixed.
- model.e2e.test.ts requires the assertion fix before merge
<sub>Last reviewed commit: 241a058</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#13626: fix(model): propagate provider model properties in fallback resolution
by mcaxtr · 2026-02-10
82.1%
#9905: fix: require provider prefix for models set without alias (#5790)
by petter-b · 2026-02-05
79.9%
#14744: fix(context): key MODEL_CACHE by provider/modelId to prevent collis...
by lailoo · 2026-02-12
79.3%
#7570: fix: allow models from providers with auth profiles configured
by DonSqualo · 2026-02-03
79.3%
#3322: fix: merge provider config api into registry model
by nulone · 2026-01-28
79.3%
#21638: fix(models): surface models.json validation errors instead of faili...
by aldoeliacim · 2026-02-20
79.3%
#15632: fix: use provider-qualified key in MODEL_CACHE for context window l...
by linwebs · 2026-02-13
78.7%
#9822: fix: allow local/custom model providers for sub-agent inference
by stammtobias91 · 2026-02-05
78.2%
#22069: fix(agents): add provider-specific hints for local model auth errors
by pierreeurope · 2026-02-20
77.6%
#16838: fix: include configured fallbacks in model allowlist
by taw0002 · 2026-02-15
77.4%