You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: prefer LiteLLM model_info.display_name for model names - #56
Use LiteLLM's model_info.display_name as a discovered model's display name when it is set, falling back to the existing id formatting when it is missing or invalid. Display-only: model ids, request names, routing, filtering, capabilities, pricing and Responses API routing are unchanged.
Precedence: explicit models.<id>.name > formatModelNames: false (raw id) > valid display_name > formatModelName(). modelNameTemplate applies to the resolved name, and OpenCode 1's Responses sibling keeps the display_name when re-resolving {provider_id} / {provider_name} (cold and warm cache). CACHE_VERSION is bumped 6 → 7 so earlier caches are re-discovered once, and a changed display_name propagates through the existing background refresh.
Type of change
🐛 Bug fix (non-breaking)
✨ New feature (non-breaking)
💥 Breaking change
📝 Documentation only
🔧 Internal / refactor
Checklist
npm run typecheck passes
No new runtime dependencies (or justified in this PR description)
npm run typecheck clean; npm test — 13 files / 261 tests.
Live LiteLLM proxy with OpenCode 2.2.5 and Node.js 24. /v1/model/info returned 260 entries, one with model_info.display_name (qwen3.8-max → Qwen3.8 Max).
Default: qwen3.8-max resolves to Qwen3.8 Max.
formatModelNames: false: resolves to the raw id qwen3.8-max.
modelNameTemplate: "{name} ({provider_name})": resolves to Qwen3.8 Max (Team A).
A model without display_name (qwen3.8-flash) still falls back to formatModelName() → Qwen3 8 Flash.
Model ids, request names and Responses routing were unchanged.
Covered by tests: test/to-config-model.test.ts (precedence, invalid values, template), test/plugin-v1.test.ts (warm/cold Responses sibling, explicit name override, raw id mode), test/plugin-v2.test.ts (v2 reflection and background refresh), test/model-cache.test.ts (v7 round-trip, old-version miss), test/litellm-api.test.ts (alias matching).
Not exercised end-to-end: the OpenCode TUI/Desktop picker, an OpenCode 1 host, and a real mode: responses model (the test proxy has none); those paths are covered by the mocked integration tests.
No actionable comments were generated in the recent review.
Walkthrough
Model discovery now prefers a valid LiteLLM model_info.display_name when name formatting is enabled. Model templates use the resolved name, and the cache stores display names for later rendering and refresh.
Changes: LiteLLM display-name resolution and persistence
The model metadata type now includes optional display_name. Name resolution trims valid values and otherwise uses the formatted or raw model ID. Templates receive the resolved name, and documentation describes the precedence and fallback behavior.
Discover and render display names src/plugin/index.ts, test/litellm-api.test.ts, test/plugin-v1.test.ts, test/plugin-v2.test.ts
Discovery records valid display names and supplies them to model rendering, including Responses-provider templates. Tests cover display-name aliases, unchanged model IDs and routing, formatting-disabled behavior, and rendering cached names.
The cache version changes from 6 to 7 and cache entries store normalized display names. Initial discovery and refresh writes in both plugin paths include the names. Tests cover cache normalization, version invalidation, and refreshed names.
Issue 52: This change applies modelNameTemplate to the resolved display name, but does not add the per-provider placeholders requested by the issue.
Possibly related PRs
yuseferi/opencode-litellm#55: Both PRs change the model-name template flow; this change updates the name source and preserves it when Responses siblings are re-rendered.
yuseferi/opencode-litellm#47: Both PRs change the model cache version; this change advances it from 6 to 7 and treats version 6 entries as cache misses.
Suggested reviewers:yuseferi, mkowalski, zyc
Merge Risk: Minimal · up to e481a
No actionable merge-blocking issue was identified. Display-name handling and cache propagation appear consistent with the documented precedence; merge after normal checks pass.
Pre-merge checks: 5
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "feat: prefer LiteLLM model_info.display_name for model names" matches the main change. The PR makes LiteLLM model_info.display_name the preferred display-name source, ahead of formatted or …
Docstring Coverage
Docstring coverage is 84.62% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "feat: prefer LiteLLM model_info.display_name for model names" matches the main change. The PR makes LiteLLM model_info.display_name the preferred display-name source, ahead of formatted or raw model IDs, and the changeset implements that across discovery, caching, naming, and tests. The title is concise, specific, and free of file lists or vague terms.
Full details: Docstring Coverage
Explanation
Docstring coverage is 84.62% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 13 functions across 11 files. (2 skipped: 2 unsupported.)
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Tip
🎯 Customize your risk assessments
Guide how CodeRabbit assesses merge risk and security architecture risk. Highlight sensitive changes and explain your security boundaries using Merge Risk Instructions and Security Risk Instructions in your review settings. Security architecture risk assessments require the Advanced plan or above.
✅ Automatic approvals, with your rules
Let CodeRabbit approve pull requests once required threads are resolved, pre-merge checks pass, and your risk limits are met. Enable Automatic approvals in review settings, with overrides for teams or file paths.
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.
File: No configuration file from this repository applied
Commit: Unavailable
Layers: defaults
Review profile: CHILL
Plan: Advanced
Run ID: 727318f2-21e3-4e26-842d-a7bffe46f10c
Commits
Reviewing files that changed from the base of the PR and between bd4d7da and e481a71.
Files selected for processing: 13
CHANGELOG.md
README.md
src/plugin/index.ts
src/plugin/v2.ts
src/types/index.ts
src/utils/format-model-name.ts
src/utils/litellm-api.ts
src/utils/model-cache.ts
test/litellm-api.test.ts
test/model-cache.test.ts
test/plugin-v1.test.ts
test/plugin-v2.test.ts
test/to-config-model.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Use LiteLLM's
model_info.display_nameas a discovered model's display name when it is set, falling back to the existing id formatting when it is missing or invalid. Display-only: model ids, request names, routing, filtering, capabilities, pricing and Responses API routing are unchanged.Precedence: explicit
models.<id>.name>formatModelNames: false(raw id) > validdisplay_name>formatModelName().modelNameTemplateapplies to the resolved name, and OpenCode 1's Responses sibling keeps thedisplay_namewhen re-resolving{provider_id}/{provider_name}(cold and warm cache).CACHE_VERSIONis bumped 6 → 7 so earlier caches are re-discovered once, and a changeddisplay_namepropagates through the existing background refresh.Type of change
Checklist
npm run typecheckpassesCHANGELOG.mdupdated under## [Unreleased]How was this tested?
npm run typecheckclean;npm test— 13 files / 261 tests./v1/model/inforeturned 260 entries, one withmodel_info.display_name(qwen3.8-max→Qwen3.8 Max).qwen3.8-maxresolves toQwen3.8 Max.formatModelNames: false: resolves to the raw idqwen3.8-max.modelNameTemplate: "{name} ({provider_name})": resolves toQwen3.8 Max (Team A).display_name(qwen3.8-flash) still falls back toformatModelName()→Qwen3 8 Flash.test/to-config-model.test.ts(precedence, invalid values, template),test/plugin-v1.test.ts(warm/cold Responses sibling, explicit name override, raw id mode),test/plugin-v2.test.ts(v2 reflection and background refresh),test/model-cache.test.ts(v7 round-trip, old-version miss),test/litellm-api.test.ts(alias matching).mode: responsesmodel (the test proxy has none); those paths are covered by the mocked integration tests.