[PR #12170] fix(provider): preserve user-defined model variants from config #14100

Open
opened 2026-02-16 18:18:54 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/12170

State: open
Merged: No


Summary

Fixes a subtle bug where model.variants could be unintentionally overwritten when ProviderTransform.variants() returns {} for certain models (kimi, deepseek, minimax, etc.).

The Problem

In provider.ts, the previous code would:

  1. Overwrite model.variants with ProviderTransform.variants(model) result (which is {} for kimi models)
  2. Then conditionally merge with configVariants

While this currently works, it has a subtle issue: if configVariants lookup fails or if variants were set in a previous processing step, they would be lost.

The Fix

Instead of overwriting then merging, we now merge directly:

  • ProviderTransform.variants() provides the base defaults
  • model.variants (from user config) is merged on top, taking precedence
  • User-defined variants are always preserved

Changes

  • Modified packages/opencode/src/provider/provider.ts (lines 925-932)
  • Simplified variant merging logic
  • Ensures user config always takes precedence over ProviderTransform defaults

Testing

  • Tested with custom provider configs (e.g., kimi-for-coding with kimi-k2.5 model)
  • Verified that user-defined variants in config are properly preserved
  • No breaking changes to existing behavior

Related

Closes #12169

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/12170 **State:** open **Merged:** No --- ## Summary Fixes a subtle bug where `model.variants` could be unintentionally overwritten when `ProviderTransform.variants()` returns `{}` for certain models (kimi, deepseek, minimax, etc.). ## The Problem In `provider.ts`, the previous code would: 1. Overwrite `model.variants` with `ProviderTransform.variants(model)` result (which is `{}` for kimi models) 2. Then conditionally merge with `configVariants` While this currently works, it has a subtle issue: if `configVariants` lookup fails or if variants were set in a previous processing step, they would be lost. ## The Fix Instead of overwriting then merging, we now merge directly: - `ProviderTransform.variants()` provides the base defaults - `model.variants` (from user config) is merged on top, taking precedence - User-defined variants are always preserved ## Changes - Modified `packages/opencode/src/provider/provider.ts` (lines 925-932) - Simplified variant merging logic - Ensures user config always takes precedence over ProviderTransform defaults ## Testing - Tested with custom provider configs (e.g., kimi-for-coding with kimi-k2.5 model) - Verified that user-defined variants in config are properly preserved - No breaking changes to existing behavior ## Related Closes #12169
yindo added the pull-request label 2026-02-16 18:18:54 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#14100