[PR #7140] Add default variant config per agent #12267

Closed
opened 2026-02-16 18:17:11 -05:00 by yindo · 0 comments
Owner

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

State: closed
Merged: No


All changes are in place. Let me create a summary of the implementation:

Summary

I've implemented the default variant configuration per agent feature as specified in the issue. Here are the changes made:

Files Modified

  1. packages/opencode/src/config/config.ts (lines 481, 497):

    • Added variant field to Config.Agent schema with description
    • Added variant to knownKeys set for proper parsing
  2. packages/opencode/src/agent/agent.ts (lines 37, 194):

    • Added variant field to Agent.Info type
    • Added parsing logic to read variant from config during agent state initialization
  3. packages/opencode/src/session/llm.ts (lines 86-87):

    • Updated variant resolution to use input.user.variant ?? input.agent.variant as the variant key
    • This implements the priority order: explicit user selection > agent's configured default > none
  4. packages/opencode/src/tool/task.ts (line 135):

    • Pass agent.variant to subagent sessions so they use their own configured variant

Usage

Users can now configure a default variant for each agent:

{
  "agent": {
    "build": {
      "model": "anthropic/claude-sonnet-4-5-thinking",
      "variant": "high"
    },
    "explore": {
      "model": "google/gemini-3-flash",
      "variant": "low"
    }
  }
}

Variant Priority Order

  1. Explicit user selection (--variant flag or ctrl+t)
  2. Agent's configured default variant (agent.variant)
  3. None (model's base behavior)

Subagent Behavior

Subagents now use their own configured agent.variant rather than inheriting the parent's --variant override, respecting explicit per-agent configuration.

Closes #7138

New%20session%20-%202026-01-06T23%3A49%3A15.558Z
opencode session  |  github run

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/7140 **State:** closed **Merged:** No --- All changes are in place. Let me create a summary of the implementation: ## Summary I've implemented the default variant configuration per agent feature as specified in the issue. Here are the changes made: ### Files Modified 1. **`packages/opencode/src/config/config.ts`** (lines 481, 497): - Added `variant` field to `Config.Agent` schema with description - Added `variant` to `knownKeys` set for proper parsing 2. **`packages/opencode/src/agent/agent.ts`** (lines 37, 194): - Added `variant` field to `Agent.Info` type - Added parsing logic to read `variant` from config during agent state initialization 3. **`packages/opencode/src/session/llm.ts`** (lines 86-87): - Updated variant resolution to use `input.user.variant ?? input.agent.variant` as the variant key - This implements the priority order: explicit user selection > agent's configured default > none 4. **`packages/opencode/src/tool/task.ts`** (line 135): - Pass `agent.variant` to subagent sessions so they use their own configured variant ### Usage Users can now configure a default variant for each agent: ```json { "agent": { "build": { "model": "anthropic/claude-sonnet-4-5-thinking", "variant": "high" }, "explore": { "model": "google/gemini-3-flash", "variant": "low" } } } ``` ### Variant Priority Order 1. Explicit user selection (`--variant` flag or `ctrl+t`) 2. Agent's configured default variant (`agent.variant`) 3. None (model's base behavior) ### Subagent Behavior Subagents now use their own configured `agent.variant` rather than inheriting the parent's `--variant` override, respecting explicit per-agent configuration. Closes #7138 <a href="https://opencode.ai/s/FsneaBxl"><img width="200" alt="New%20session%20-%202026-01-06T23%3A49%3A15.558Z" src="https://social-cards.sst.dev/opencode-share/TmV3IHNlc3Npb24gLSAyMDI2LTAxLTA2VDIzOjQ5OjE1LjU1OFo=.png?model=opencode/claude-opus-4-5&version=1.1.4&id=FsneaBxl" /></a> [opencode session](https://opencode.ai/s/FsneaBxl)&nbsp;&nbsp;|&nbsp;&nbsp;[github run](/anomalyco/opencode/actions/runs/20765737082)
yindo added the pull-request label 2026-02-16 18:17:11 -05:00
yindo closed this issue 2026-02-16 18:17:11 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12267