← Back to PRs

#13626: fix(model): propagate provider model properties in fallback resolution

by mcaxtr open 2026-02-10 19:27 View on GitHub →
agents size: S trusted-contributor experienced-contributor
## Summary Fixes #13575 The generic fallback in `resolveModel()` had two bugs when constructing a model from provider config: 1. **`reasoning: false` hardcoded** — ignored the matched model's `reasoning` setting, preventing `reasoning.effort` from being forwarded to the API (e.g. Ollama models with `reasoning: true`) 2. **`models[0]` for contextWindow/maxTokens** — read from the first model in the provider's array instead of the matched model, causing incorrect context limits when multiple models are configured The fix finds the matched model by ID from the provider config and propagates all its properties (`reasoning`, `input`, `cost`, `contextWindow`, `maxTokens`, `name`, `api`) instead of using hardcoded defaults or the first model in the array. ## Test plan - [x] Add test: fallback does not bleed contextWindow from unrelated `models[0]` - [x] Add test: fallback propagates reasoning from matched provider model - [x] Add test: fallback uses correct model when provider has multiple models - [x] All 3 new tests fail before the fix, pass after - [x] All 13 tests pass (`npx vitest run src/agents/pi-embedded-runner/model.test.ts`) - [x] `pnpm build && pnpm check` clean <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> Fixed two bugs in the generic fallback path of `resolveModel()` when constructing models from provider config: - **`reasoning` propagation**: Previously hardcoded to `false`, now reads from matched model config (e.g., Ollama models with `reasoning: true`) - **`contextWindow`/`maxTokens` selection**: Previously read from `models[0]` regardless of which model was requested, now reads from the matched model Added comprehensive test coverage for all three scenarios (unmatched model using defaults, matched model with reasoning, multiple models selecting the correct one). The fix properly finds the matched model by trimmed ID and propagates all its properties (`reasoning`, `input`, `cost`, `contextWindow`, `maxTokens`, `name`, `api`). Previous review comments about trimming inconsistencies have been addressed in follow-up commits. <h3>Confidence Score: 5/5</h3> - Safe to merge with no blocking issues - The implementation correctly fixes both documented bugs with proper test coverage. All three new tests target the exact scenarios described in the PR (bleeding contextWindow, reasoning propagation, multiple model selection). Previous review concerns about trimming have been addressed. The logic is straightforward and the changes are minimal and focused. - No files require special attention <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs