feat(plugin): filter discovered models via includeModels/excludeModels - #21
feat(plugin): filter discovered models via includeModels/excludeModels#21zyc wants to merge 1 commit into
Conversation
Adds per-provider includeModels/excludeModels options (glob patterns, * only) so a single LiteLLM proxy can be split across several OpenCode providers -- e.g. one per upstream naming prefix -- without hand- maintaining a model list per provider. includeModels is evaluated first (default: everything passes), excludeModels afterwards and always wins. Applied in both the config hook (src/plugin/index.ts, the path OpenCode actually executes) and discoverBucket (src/plugin/discover.ts, the V2-schema path kept for consistency -- it has no callers today, so this is unreachable code, same as the rest of that file). Also fixes an idempotency-cache bug: injectedModelIds was keyed only by baseURL, so any two providers sharing a baseURL clobber each other's injected-model tracking on every config-hook invocation, defeating the "repeat invocations are a no-op" guarantee. This already affects the existing litellm/litellm-responses pairing (README "Reasoning models") -- includeModels/excludeModels just adds another way to hit it, by design. Now keyed by providerId:baseURL. In the config hook only (discoverBucket has no equivalent logging to begin with), also warns when includeModels/excludeModels removes every non-wildcard discovered model for a provider, since a typo'd glob pattern is the likeliest way to misuse this feature and it would otherwise just leave the provider silently empty.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe plugin adds ChangesModel discovery filtering
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This change adds configurable model filtering and an idempotency-key fix without any identified current-head merge-blocking risk; it is merge-ready after normal checks and review. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
Adds per-provider
includeModels/excludeModelsoptions (glob patterns,*only) so a single LiteLLM proxy's catalog can be split across several OpenCode providers — e.g. one per naming prefix — without hand-maintaining a model list per provider. Also fixes a pre-existing idempotency-cache bug that already affects thelitellm/litellm-responsespairing documented in the README.Type of change
(Also includes a small non-breaking bug fix as a drive-by — see below.)
Checklist
npm run typecheckpassesCHANGELOG.mdupdated under## [Unreleased]Details
includeModelsis evaluated first (default: everything passes, so this is fully backward-compatible for anyone not setting either option);excludeModelsis evaluated after and always wins. Implemented insrc/utils/model-filter.tswith a minimal*-only glob-to-regex conversion (no new dependency).src/plugin/index.ts, the path OpenCode actually executes) anddiscoverBucket(src/plugin/discover.ts, the V2-schema path — it has no callers today, kept in sync for consistency with the rest of that file).injectedModelIdswas keyed only bybaseURL, so any two providers sharing a proxy clobber each other's idempotency tracking on everyconfig-hook invocation, defeating the "repeat invocations are a no-op" guarantee. This already affects the existinglitellm/litellm-responsespairing (README "Reasoning models") —includeModels/excludeModelsjust adds another way to hit it. Now keyed byproviderId:baseURL.includeModels/excludeModelsremoves every discovered model for a provider, since a typo'd glob pattern is the likeliest misuse and would otherwise leave the provider silently empty.How was this tested?
npm run typecheck(only check this repo's CI runs — no test suite exists yet).gpt-4.1,claude-3.5-sonnet) to confirm they're matched literally, not misinterpreted as regex.excludeModels-only, one combiningincludeModels+excludeModels) splitting the same proxy's catalog into two OpenCode providers — confirmed via the plugin's own discovery log line andopencode models --verbose.Summary by CodeRabbit
New Features
includeModelsandexcludeModelsglob patterns.Documentation