Skip to content

feat: prefer LiteLLM model_info.display_name for model names - #56

Open
temeteke wants to merge 1 commit into
yuseferi:mainfrom
temeteke:feat/litellm-display-name
Open

temeteke wants to merge 1 commit into
yuseferi:mainfrom
temeteke:feat/litellm-display-name

Conversation

@temeteke

@temeteke temeteke commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

Summary

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)
  • README updated if public API or behavior changed
  • CHANGELOG.md updated under ## [Unreleased]
  • Commit messages follow Conventional Commits

How was this tested?

  • 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.

@coderabbitai

coderabbitai Bot commented Nov 7, 2026 •

Copy link
Copy Markdown

Explain Change →

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

Layer / File(s) Summary
Resolve names and apply templates
src/types/index.ts, src/utils/format-model-name.ts, src/plugin/index.ts, src/utils/litellm-api.ts, test/to-config-model.test.ts, README.md, CHANGELOG.md
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.
Persist display names across cache refreshes
src/utils/model-cache.ts, src/plugin/index.ts, src/plugin/v2.ts, test/model-cache.test.ts, test/plugin-v1.test.ts, test/plugin-v2.test.ts
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.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant LiteLLM
  participant Discovery
  participant ModelCache
  participant ModelRenderer
  LiteLLM->>Discovery: Return model_info.display_name
  Discovery->>ModelCache: Persist discovered display names
  ModelCache->>ModelRenderer: Provide cached display names
  Discovery->>ModelRenderer: Provide discovered display names
Loading

Possibly related issues

  • 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: Passed 5

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 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 Passed 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 Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed 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.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant