fix(litellm): enrich model discovery with info#10
Conversation
|
Warning Review limit reached
Next review available in: 58 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughLiteLLM discovery now retrieves and merges ChangesModel discovery and OpenCode integration
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant ConfigHook
participant LiteLLMModels
participant LiteLLMModelInfo
participant OpenCodeConfig
ConfigHook->>LiteLLMModels: Fetch /v1/models
ConfigHook->>LiteLLMModelInfo: Fetch /v1/model/info
LiteLLMModels-->>ConfigHook: Return model entries
LiteLLMModelInfo-->>ConfigHook: Return capability metadata
ConfigHook->>OpenCodeConfig: Add filtered enriched models
ConfigHook->>ConfigHook: Cache injected model ids
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
src/utils/litellm-api.ts (1)
112-119: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winGeneralize the
litellm_paramsfallback beyondsupports_vision.Only
supports_visionis backfilled fromlitellm_paramswhen missing frommodel_info. The comment implies this is just one example of a broader class of deployments that put capability flags on the params block, butsupports_function_calling,supports_reasoning,supports_pdf_input, andsupports_audio_inputaren't covered, so those capabilities can be silently missed for the same class of deployments.♻️ Proposed generalization
const info: LiteLLMModelInfo = { ...entry.model_info } - const paramsVision = entry.litellm_params?.supports_vision - if (info.supports_vision == null && typeof paramsVision === 'boolean') { - info.supports_vision = paramsVision - } + const capabilityFlags = [ + 'supports_vision', + 'supports_function_calling', + 'supports_reasoning', + 'supports_pdf_input', + 'supports_audio_input', + ] as const + for (const flag of capabilityFlags) { + if (info[flag] == null) { + const paramsValue = entry.litellm_params?.[flag] + if (typeof paramsValue === 'boolean') { + info[flag] = paramsValue + } + } + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/utils/litellm-api.ts` around lines 112 - 119, Generalize the fallback logic in the model-info enrichment block beyond supports_vision: for supports_function_calling, supports_reasoning, supports_pdf_input, and supports_audio_input, copy boolean values from entry.litellm_params into info only when the corresponding info field is missing. Preserve the existing supports_vision behavior and use the LiteLLMModelInfo capability fields consistently.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 254-256: Update the diagram’s final picker step to state that it
renders all eligible discovered chat models, replacing the wording that says it
renders all discovered models. Keep the surrounding model-enrichment and
filtering flow unchanged.
- Around line 267-270: Update README step 4 to say models are converted into
OpenCode model entries keyed by id, replacing the wording that says entries are
“with id”; preserve the other listed metadata and behavior.
In `@src/plugin/index.ts`:
- Around line 16-17: Increase DISCOVERY_TIMEOUT_MS to cover the sequential
health-check and model-discovery phases: use a budget at least equal to
HEALTH_TIMEOUT_MS plus FETCH_TIMEOUT_MS, while keeping the existing concurrent
Promise.allSettled behavior in work() unchanged.
---
Nitpick comments:
In `@src/utils/litellm-api.ts`:
- Around line 112-119: Generalize the fallback logic in the model-info
enrichment block beyond supports_vision: for supports_function_calling,
supports_reasoning, supports_pdf_input, and supports_audio_input, copy boolean
values from entry.litellm_params into info only when the corresponding info
field is missing. Preserve the existing supports_vision behavior and use the
LiteLLMModelInfo capability fields consistently.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 41579e61-abf6-4032-8b29-5665a316454f
📒 Files selected for processing (6)
CHANGELOG.mdREADME.mdsrc/plugin/build-model.tssrc/plugin/index.tssrc/types/index.tssrc/utils/litellm-api.ts
|
Addressed the review-summary capability fallback nitpick in 7676ed1: |
|
@yuseferi WDYT? |
|
hey @overbit , |
Summary
Closes: #9
Fixes non-chat (embedding/image/audio) models appearing in the OpenCode picker and missing capability metadata (vision, reasoning, limits) for database-defined LiteLLM models. Discovery now enriches
/v1/modelswith/v1/model/info— with alias-tolerant matching, a realistic fetch timeout for remote proxies, and visible warnings when enrichment degrades — and maps LiteLLM capability flags to OpenCode'sreasoningandmodalitiesfields.Type of change
Checklist
npm run typecheckpassesCHANGELOG.mdupdated under## [Unreleased]How was this tested?
tsc --noEmitclean (Node 24, TypeScript 5.9).confighook against a mock LiteLLM HTTP server (20 assertions) replicating payloads observed on LiteLLM 1.89.2 with database-defined models:/v1/modelsentries withoutmode— embedding models are hidden once/v1/model/infosuppliesmode: embedding, including ids with no "embed" substring;model_name: gemini/gemini-3.6-flashvsmodel_info.key: gemini/gemini-3.5-flash) — enrichment still lands via multi-key indexing (model_name/model_info.key/litellm_params.model);mode: nullmoonshot entries withsupports_visiononlitellm_params— vision, reasoning, pdf/audio flags map to OpenCodeattachment,reasoning, andmodalities.input;deepseek/*wildcard access-rule entries are hidden;model_nameinfo entries (wildcard expansion) are deduped;/v1/model/inforeturning HTTP 500 — discovery degrades to id heuristics with a logged warning, chat models still load;confighook invocations (OpenCode calls it multiple times per run) are a no-op with zero extra HTTP requests.Screenshots / logs (optional)
```
[opencode-litellm] Discovered 18 models from https://litellm.example.com (16 added, 1 non-chat hidden, 1 wildcard ignored)
[opencode-litellm] /v1/model/info unavailable; non-chat model filtering will use id heuristics only:
```
Summary by CodeRabbit
New Features
Bug Fixes