[FEATURE]: Add --variant flag to root opencode command #4444

Open
opened 2026-02-16 17:43:48 -05:00 by yindo · 3 comments
Owner

Originally created by @ekweible on GitHub (Jan 8, 2026).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

The --variant flag was added to opencode run in #6805 but is missing from the root opencode command.

Current Behavior

# Works
opencode run --model anthropic/claude-sonnet-4-20250514 --variant max "hello"
# Doesn't work - variant flag not recognized
opencode --model anthropic/claude-sonnet-4-20250514 --variant max --prompt "hello"

Expected Behavior

Both commands should support --variant.

This matters most when --prompt is provided since the model responds immediately - users can't control reasoning effort for that initial response.

Relevant Files

File Current State
src/cli/cmd/run.ts:90-93 Has --variant option
src/cli/cmd/tui/thread.ts Missing --variant option
src/cli/cmd/tui/context/args.tsx Args interface lacks variant

Implementation Notes

The variant infrastructure already exists in the TUI. Changes needed:

  1. thread.ts: Add --variant option to yargs builder
  2. args.tsx: Add variant?: string to Args interface
  3. thread.ts: Pass variant through to tui() args
  4. local.tsx: Initialize variant from CLI arg (similar to how args.model is handled at line 142)

The variant management (model.variant.set(), model.variant.current(), etc.) is already implemented in local.tsx:310-347, so this is just a CLI argument threading task.

Originally created by @ekweible on GitHub (Jan 8, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request The `--variant` flag was added to `opencode run` in #6805 but is missing from the root `opencode` command. ## Current Behavior ```bash # Works opencode run --model anthropic/claude-sonnet-4-20250514 --variant max "hello" # Doesn't work - variant flag not recognized opencode --model anthropic/claude-sonnet-4-20250514 --variant max --prompt "hello" ``` ## Expected Behavior Both commands should support `--variant`. This matters most when `--prompt` is provided since the model responds immediately - users can't control reasoning effort for that initial response. ## Relevant Files | File | Current State | | ---------------------------------- | -------------------------------- | | `src/cli/cmd/run.ts:90-93` | Has `--variant` option | | `src/cli/cmd/tui/thread.ts` | Missing `--variant` option | | `src/cli/cmd/tui/context/args.tsx` | `Args` interface lacks `variant` | ## Implementation Notes The variant infrastructure already exists in the TUI. Changes needed: 1. **`thread.ts`**: Add `--variant` option to yargs builder 2. **`args.tsx`**: Add `variant?: string` to `Args` interface 3. **`thread.ts`**: Pass `variant` through to `tui()` args 4. **`local.tsx`**: Initialize variant from CLI arg (similar to how `args.model` is handled at line 142) The variant management (`model.variant.set()`, `model.variant.current()`, etc.) is already implemented in `local.tsx:310-347`, so this is just a CLI argument threading task.
yindo added the discussion label 2026-02-16 17:43:48 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 8, 2026):

This issue relates to #7138 which implements default variant configuration per agent. While this issue (#7354) focuses on adding the --variant CLI flag to the root command, #7138 adds per-agent default variants in the config. Both approaches are complementary:

  • #7138: Set default variant in config (e.g., build agent always uses high variant)
  • #7354: Override via CLI flag (e.g., opencode --variant max --prompt ...)

These work together to give users flexible variant control at both the configuration and CLI levels.

@github-actions[bot] commented on GitHub (Jan 8, 2026): This issue relates to #7138 which implements default variant configuration per agent. While this issue (#7354) focuses on adding the `--variant` CLI flag to the root command, #7138 adds per-agent default variants in the config. Both approaches are complementary: - #7138: Set default variant in config (e.g., `build` agent always uses `high` variant) - #7354: Override via CLI flag (e.g., `opencode --variant max --prompt ...`) These work together to give users flexible variant control at both the configuration and CLI levels.
Author
Owner

@ekweible commented on GitHub (Jan 8, 2026):

This one seemed fairly straightforward and given that opencode run already supports it, I assumed it would be reasonable to have on the root command, too, so I opened a PR here: https://github.com/anomalyco/opencode/pull/7358

Feel free to close if that's not the case!

@ekweible commented on GitHub (Jan 8, 2026): This one seemed fairly straightforward and given that `opencode run` already supports it, I assumed it would be reasonable to have on the root command, too, so I opened a PR here: https://github.com/anomalyco/opencode/pull/7358 Feel free to close if that's not the case!
Author
Owner

@gjermundgaraba commented on GitHub (Jan 15, 2026):

Just to add to this, would like to see this added.
For context, I use the root opencode command to quickly spin up a code review with a script that creates a worktree for a PR's branch and launches opencode with a prompt (using a custom slash command). The reason I want variant is becuase I want to use max for claude and xhigh for codex (I usually like to run one with each).

I am using a fork locally for this, right now, but would love to get this functionality upstreamed. I'll link my fork's commit in the PR, in case there is anything useful there :)

@gjermundgaraba commented on GitHub (Jan 15, 2026): Just to add to this, would like to see this added. For context, I use the root opencode command to quickly spin up a code review with a script that creates a worktree for a PR's branch and launches opencode with a prompt (using a custom slash command). The reason I want variant is becuase I want to use `max` for claude and `xhigh` for codex (I usually like to run one with each). I am using a fork locally for this, right now, but would love to get this functionality upstreamed. I'll link my fork's commit in the PR, in case there is anything useful there :)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4444