← Back to PRs

#21882: feat(gateway): filter models.list by agents.defaults.models allowlist

by kckylechen1 open 2026-02-20 13:54 View on GitHub →
gateway size: XS
## 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