#21882: feat(gateway): filter models.list by agents.defaults.models allowlist
gateway
size: XS
Cluster:
Model Management Enhancements
## Summary
When `agents.defaults.models` is configured, the gateway `models.list` RPC now returns only the allowed subset plus any custom provider models, instead of the full 700+ model catalog.
This makes the TUI `/models` picker show only actionable models that the user has explicitly allowlisted.
When no allowlist is set (`allowAny`), the full catalog is returned unchanged — no behavioral change for users without an allowlist.
## Changes
- **`src/gateway/server-methods/models.ts`**: Apply `buildAllowedModelSet` to filter the catalog before returning. Also includes models from `allowedKeys` that aren't in the built-in catalog (custom providers from `models.providers`).
## Testing
- TUI model picker shows only allowlisted models (14 vs 713)
- Custom provider models (volcengine, zai, minimax-portal, xianyu) appear correctly
- `pnpm build` passes
- No change for users without an allowlist
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Filters the `models.list` RPC response to return only allowlisted models from `agents.defaults.models` configuration, reducing the model picker from 700+ models to only actionable models.
- Applied `buildAllowedModelSet` filter to catalog before returning
- Preserves full catalog when no allowlist is configured (`allowAny`)
- Includes custom provider models from `models.providers` that aren't in built-in catalog
- Backward compatible: no behavior change for users without an allowlist
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The implementation is straightforward, reuses existing battle-tested logic from `buildAllowedModelSet`, maintains backward compatibility, and the PR description confirms it passes build and manual testing. The code correctly handles edge cases (empty allowlist, custom providers, duplicate detection).
- No files require special attention
<sub>Last reviewed commit: 644c1a4</sub>
<!-- 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
#9583: fix(models): allow models in agents.defaults.models even if not in ...
by hotzen100 · 2026-02-05
84.0%
#14508: fix(models): allow forward-compat models in allowlist check
by jonisjongithub · 2026-02-12
81.1%
#11349: fix(agents): do not filter fallback models by models allowlist
by liuxiaopai-ai · 2026-02-07
79.1%
#17021: fix(agents): read models from gateway config first
by Limitless2023 · 2026-02-15
79.0%
#6673: fix: preserve allowAny flag in createModelSelectionState for custom...
by tenor0 · 2026-02-01
78.5%
#7570: fix: allow models from providers with auth profiles configured
by DonSqualo · 2026-02-03
78.4%
#20954: feat: per-agent model allowlist
by coletebou · 2026-02-19
78.4%
#10608: fix(agents): honor spawn model override in gateway and session spaw...
by 1kuna · 2026-02-06
77.3%
#8174: feat(wizard): strict model filtering for preferred providers
by gkamboj-bot · 2026-02-03
77.1%
#6603: fix: use allowAny flag instead of size check for model override val...
by gavinbmoore · 2026-02-01
77.0%