#7570: fix: allow models from providers with auth profiles configured
agents
Cluster:
Model Management Enhancements
## Problem
When using providers like OpenRouter with dynamically-routed models (e.g. `openrouter/moonshotai/kimi-k2.5`), the model would be rejected with "model not allowed" or "Unknown model" even when:
1. The model was listed in `agents.defaults.models`
2. The provider had auth configured in `auth.profiles` (e.g. `openrouter:default`)
This happened because:
1. `buildAllowedModelSet` only checked `models.providers` for non-catalog models
2. `resolveModel` would fail to create a fallback model without explicit provider config
3. Even when a fallback was created, it was missing the `baseUrl` needed for API routing
## Solution
1. **model-selection.ts**: Extract providers from `auth.profiles` and allow models from those providers in the allowlist check
2. **pi-embedded-runner/model.ts**:
- Check auth profiles when deciding whether to create a fallback model
- Add known provider base URLs (OpenRouter, Together, Groq, DeepSeek) for dynamic routing
## Testing
Tested with `openrouter/moonshotai/kimi-k2.5` via `sessions_spawn`:
- Before: "model not allowed" → "Unknown model"
- After: Kimi responds correctly, identifies as Moonshot AI's model
## Breaking Changes
None. This is additive - existing configs continue to work.
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR extends model allowlisting and pi embedded model resolution to treat providers with configured `auth.profiles` (e.g. `openrouter:default`) as “configured” even when they aren’t present in the curated model catalog or in `cfg.models.providers`. It also adds a small known-base-URL map in `pi-embedded-runner/model.ts` so dynamically-routed providers (OpenRouter/Together/Groq/DeepSeek) can form a usable fallback `Model` for unknown model IDs.
The change fits into the existing flow where `buildAllowedModelSet` gates user-configured `agents.defaults.models`, and `resolveModel` builds an inline/fallback model when the model registry can’t resolve it.
<h3>Confidence Score: 4/5</h3>
- This PR is likely safe to merge, with small edge cases around fallback baseUrl and provider key normalization.
- Core logic change is additive and scoped to allowlisting/fallback creation, but the new “auth-profile-only provider” path can still produce a fallback model with `baseUrl` undefined for providers not in the hardcoded map, and the allowlist’s explicit provider-config check may not match config keys if they aren’t normalized.
- src/agents/pi-embedded-runner/model.ts; src/agents/model-selection.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#9583: fix(models): allow models in agents.defaults.models even if not in ...
by hotzen100 · 2026-02-05
86.5%
#14508: fix(models): allow forward-compat models in allowlist check
by jonisjongithub · 2026-02-12
85.3%
#9822: fix: allow local/custom model providers for sub-agent inference
by stammtobias91 · 2026-02-05
85.0%
#6673: fix: preserve allowAny flag in createModelSelectionState for custom...
by tenor0 · 2026-02-01
83.1%
#11349: fix(agents): do not filter fallback models by models allowlist
by liuxiaopai-ai · 2026-02-07
83.0%
#4459: fix: enable image input for Kimi K2.5 and refresh stale config mode...
by manikv12 · 2026-01-30
82.1%
#11198: fix(models): strip @profile suffix from model selection
by mcaxtr · 2026-02-07
81.9%
#13626: fix(model): propagate provider model properties in fallback resolution
by mcaxtr · 2026-02-10
81.9%
#13376: fix: pass model directly to agent for sub-agent runs
by jrbobbyhansen-pixel · 2026-02-10
81.6%
#13188: fix: add cross-provider fallback when primary provider is rate-limited
by 1bcMax · 2026-02-10
80.8%