Skip to content

Agent variant incorrectly applied to all models, causing errors with OpenAI-compatible providers #11416

@neavo

Description

@neavo

Bug Description

When configuring an agent with a specific variant (e.g., xhigh for reasoning effort), the variant is incorrectly applied to all models used by that agent, not just the model it was configured for. This causes API errors when switching to models that don't support the variant parameter.

Steps to Reproduce

  1. Configure an agent with a model and variant:
    {
      "agent": {
        "plan": {
          "model": "openai/gpt-5.2",
          "variant": "xhigh"
        }
      }
    }
  2. Use the agent with its configured model (works fine)
  3. Switch to a different model (e.g., opencode/kimi-k2.5-free) while still using the same agent
  4. The variant xhigh is still sent to the API, causing:
    Extra inputs are not permitted, field: 'variant', value: 'xhigh'
    

Expected Behavior

The variant should only be applied when using the specific model it was configured for. When switching to a different model, the variant should not be sent.

Root Cause

The variant field is currently treated as an unknown key and gets merged into agent.options, which is then passed to all API calls regardless of which model is actually being used.

Environment

  • OpenCode version: latest
  • Provider: OpenAI-compatible (opencode/zen)
  • Model: kimi-k2.5-free (and other non-OpenAI models)

Related

This issue affects any OpenAI-compatible provider that doesn't support the variant parameter, including Kimi, GLM, and other models accessed through the opencode provider.

Metadata

Metadata

Assignees

Labels

zenRelates to Zen

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions