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 |
|
Hey @zyc there are some conflict, I appreciate if you resolve the conflicts. Best |
|
Thanks for this — the feature is well motivated (splitting one proxy's catalog across providers without hand-maintained lists), the minimal Review notes before this can move forward: 1. The branch is stale and conflicts with main. 2. A real gap once the SWR cache is involved: since v0.10 the plugin serves models from an on-disk cache on the fast path and refreshes that cache in the background via
Net effect: filters work on first run, then silently stop applying after the first background refresh. On rebase, the filter needs to be applied inside 3. Once #24 merges, a rebase onto |
|
@zyc — thank you again for this contribution! Since the rebase onto the post-#24/#26 codebase would have been substantial (the surrounding It's your design and implementation — the You're very welcome to review #27 before it ships. Thanks for the feature and the patience! |
|
Closing this in favor of #27, which carries this feature onto the current codebase — with a Co-authored-by credit for @zyc. Thanks again for the contribution! The one change from the original: filtering now happens inside |
Per-provider glob filters (only `*`, everything else literal) let one LiteLLM proxy be split across several OpenCode providers without hand-maintained model lists. includeModels is evaluated first, excludeModels always wins, and empty/omitted arrays mean no filtering. Based on #21 by Cleverson Sacramento, with two changes for the post-v1.0 architecture: the filter is applied inside discoverModels() rather than at merge time, so the SWR cache and background refresh write the same filtered view instead of the filter silently lapsing after the first refresh; and the dead V2-schema path it also touched no longer exists. Co-authored-by: Cleverson Sacramento <cleverson.sacramento@gmail.com>
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