#3322: fix: merge provider config api into registry model
agents
Cluster:
Model Configuration Fixes
Fixes #1695
## Problem
When `modelRegistry.find()` returns a model, provider config `models.providers.*.api` was ignored — registry model was used as-is.
## Solution
Shallow clone + merge provider config api when `model.api` is missing.
## Changes
- `src/agents/pi-embedded-runner/model.ts` — 3 lines
- `src/agents/pi-embedded-runner/model.test.ts` — regression test
## Testing
All related tests pass ✓
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR fixes #1695 by ensuring models returned from the Pi model registry inherit the provider-level `api` from `cfg.models.providers[provider]` when the registry model lacks an `api`. It does this by shallow-cloning the registry model, filling `api` via nullish-coalescing, and then passing the merged result through `normalizeModelCompat`.
A regression test was added in `src/agents/pi-embedded-runner/model.test.ts` to cover the scenario where `discoverModels().find()` returns a model without `api` and config specifies `models.providers.lmstudio.api`.
<h3>Confidence Score: 4/5</h3>
- This PR is low-risk and likely safe to merge, but there is a small chance provider config lookup misses normalized provider IDs.
- Change is narrowly scoped (one merge point + one regression test) and preserves precedence of registry model fields. Main concern is config lookup uses the raw provider key, which may not match the normalization used elsewhere (already used for inline models), potentially leaving some cases of #1695 unresolved.
- src/agents/pi-embedded-runner/model.ts
<!-- greptile_other_comments_section -->
<sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub>
<!-- /greptile_comment -->
Most Similar PRs
#13626: fix(model): propagate provider model properties in fallback resolution
by mcaxtr · 2026-02-10
83.4%
#15205: fix(models): normalize google-antigravity api field from google-gem...
by wboudy · 2026-02-13
82.1%
#2353: fix: ensure api field is set for inline provider models
by sbknana · 2026-01-26
82.1%
#16766: fix(model): apply provider baseUrl/headers override to registry-fou...
by dzianisv · 2026-02-15
81.6%
#9212: fix: ensure model.input is always an array for custom providers
by sparck75 · 2026-02-05
81.5%
#14744: fix(context): key MODEL_CACHE by provider/modelId to prevent collis...
by lailoo · 2026-02-12
81.0%
#9739: #9291 fix(models): preserve existing models in models.json when mer...
by ximzzzzz · 2026-02-05
80.8%
#11882: fix: accept openai-codex/gpt-5.3-codex model refs
by jackberger03 · 2026-02-08
80.3%
#7570: fix: allow models from providers with auth profiles configured
by DonSqualo · 2026-02-03
79.8%
#15632: fix: use provider-qualified key in MODEL_CACHE for context window l...
by linwebs · 2026-02-13
79.7%