Skip to content

feat: add agent default variant handling in TUI and desktop - #7156

Closed
CasualDeveloper wants to merge 1 commit into
anomalyco:devfrom
CasualDeveloper:feat/7138-agent-default-variant
Closed

feat: add agent default variant handling in TUI and desktop#7156
CasualDeveloper wants to merge 1 commit into
anomalyco:devfrom
CasualDeveloper:feat/7138-agent-default-variant

Conversation

@CasualDeveloper

@CasualDeveloperCasualDeveloper commented Jan 7, 2026

Copy link
Copy Markdown
Contributor

Issue for this PR

Closes#22065

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Respect an agent's configured model variant in the app and TUI when the current model supports it.

The change keeps selected/current/configured variant resolution in a shared helper so both clients agree on:

  • user-selected variant wins
  • Default clears the active variant override
  • no saved choice falls back to the agent-configured variant
  • invalid configured variants are ignored for the current model

The PR stays client/local-state scoped; it does not add backend/session/API/SDK behavior.

How did you verify your code works?

  • bun turbo typecheck
  • From packages/opencode: bun test --timeout 900000 ./test/agent/agent.test.ts (40 pass)
  • From packages/core: bun test --timeout 900000 ./test/util/model-variant.test.ts (8 pass)

Screenshots / recordings

Not included; this changes prompt-bar metadata display/state behavior and is covered by the focused tests above.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Potential Duplicates Found

PR #7140: Add default variant config per agent
#7140

Why related: This is the primary implementation that the current PR (#7156) is an alternative version of. According to the PR description, #7156 is an alternative implementation for #7138 that includes additional changes not present in #7140, specifically:

  • Fallback to agent.variant for message metadata in prompt.ts
  • Clarifying comment explaining subagent variant design choice in task.ts

The PR author explicitly states they're "happy to close this if #7140 incorporates these changes," indicating these are addressing the same feature with slightly different approaches.

@rekram1-node

Copy link
Copy Markdown
Collaborator

@CasualDeveloper we can do ur change if u want but I think ti requires updates to both tui AND desktop

@CasualDeveloper
CasualDeveloperforce-pushed the feat/7138-agent-default-variant branch 3 times, most recently from 11edba0 to 9cc62c8CompareJanuary 8, 2026 05:59
@CasualDeveloper
CasualDeveloper marked this pull request as ready for review January 8, 2026 05:59
@CasualDeveloper
CasualDeveloperforce-pushed the feat/7138-agent-default-variant branch from 9cc62c8 to ae2dd3eCompareJanuary 8, 2026 06:14
@CasualDeveloper

Copy link
Copy Markdown
ContributorAuthor

Thanks @rekram1-node! I've updated this PR to include both TUI and desktop support:

TUI:local.tsx, prompt/index.tsx, dialog-agent.tsx
Desktop:local.tsx, prompt-input.tsx

Both now have:

  • effective() method that returns current() ?? agent.current()?.variant
  • Variant display in prompt bar
  • Variant shown in agent selector

The prompt.ts change is backend-only and works for all clients automatically.

Ready for review when you have time!

@CasualDeveloperCasualDeveloper changed the title feat: add agent-level default variant support (alternative implementation)feat: add variant support for subagents #7138 (alt pr to #7140)Jan 8, 2026
@CasualDeveloperCasualDeveloper changed the title feat: add variant support for subagents #7138 (alt pr to #7140)feat: add variant support for subagents (#7138, alt pr to #7140)Jan 8, 2026
@CasualDeveloperCasualDeveloper changed the title feat: add variant support for subagents (#7138, alt pr to #7140)feat: add variant support for subagents (#7138) [alt of #7140]Jan 8, 2026
@CasualDeveloper
CasualDeveloperforce-pushed the feat/7138-agent-default-variant branch 5 times, most recently from 07c8bd5 to 065875fCompareJanuary 11, 2026 14:31
@CasualDeveloper
CasualDeveloperforce-pushed the feat/7138-agent-default-variant branch from 065875f to 6088a6fCompareJanuary 11, 2026 18:51
@CasualDeveloper
CasualDeveloperforce-pushed the feat/7138-agent-default-variant branch 8 times, most recently from 2e9637c to d415762CompareJanuary 14, 2026 20:39
@CasualDeveloper

CasualDeveloper commented Feb 12, 2026

Copy link
Copy Markdown
ContributorAuthor

@rekram1-node rebuilt feature on top of latest origin/dev, taking into account your feedback:

  • kept core/session variant handling unchanged (no extra llm fallback logic)
  • moved variant behavior to TUI/Desktop local state only
  • aligned both clients to the same selected/configured/current/cycle helper flow
  • agent variant now works across models when that variant key exists on the active model (not locked to one model)
  • kept hydration guard so configured defaults don't get persisted as explicit overrides

Also reran typecheck + variant-focused tests locally and they pass.

@CasualDeveloper
CasualDeveloperforce-pushed the feat/7138-agent-default-variant branch 5 times, most recently from 76c9044 to 6355ca1CompareFebruary 18, 2026 14:37
@CasualDeveloper
CasualDeveloperforce-pushed the feat/7138-agent-default-variant branch 2 times, most recently from db52404 to 263a4e5CompareFebruary 25, 2026 21:47
@CasualDeveloper
CasualDeveloperforce-pushed the feat/7138-agent-default-variant branch 2 times, most recently from 0f6f922 to 0a5c0daCompareMarch 8, 2026 18:50
@CasualDeveloper
CasualDeveloperforce-pushed the feat/7138-agent-default-variant branch from 0a5c0da to 99a76acCompareMarch 25, 2026 19:28

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds agent-level default model variant handling and surfaces the effective variant in the UI, aligning TUI/Desktop behavior with per-agent configured reasoning effort.

Changes:

  • Introduces shared variant resolution helpers for the TUI (configured vs selected vs default sentinel) plus tests.
  • Updates TUI local context + prompt bar to compute/show an “effective” variant.
  • Adjusts Desktop variant cycling behavior/tests and adds variant to the triage agent config.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.

Show a summary per file
FileDescription
packages/opencode/test/cli/tui/model-variant.test.tsAdds unit coverage for variant resolution/cycling semantics in the TUI.
packages/opencode/test/agent/agent.test.tsVerifies agent variant is loaded from config and defaults to undefined.
packages/opencode/src/cli/cmd/tui/context/model-variant.tsAdds helper functions for configured-variant matching and variant resolution/cycling.
packages/opencode/src/cli/cmd/tui/context/local.tsxWires configured + selected variant resolution into the TUI local model context.
packages/opencode/src/cli/cmd/tui/component/prompt/index.tsxInitializes local agent/model/variant from the last user message; shows effective variant in prompt bar.
packages/app/src/context/model-variant.tsUpdates Desktop cycling logic (no longer advances from configured variant).
packages/app/src/context/model-variant.test.tsUpdates/adds tests to match the new Desktop cycling behavior.
packages/app/src/context/local.tsxAdds effective() alias for variant display parity.
.opencode/agent/triage.mdSets triage agent default variant: "high".

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment threadpackages/opencode/src/cli/cmd/tui/context/local.tsx Outdated
Comment threadpackages/opencode/src/cli/cmd/tui/component/prompt/index.tsx Outdated
Comment threadpackages/opencode/src/cli/cmd/tui/component/prompt/index.tsx Outdated
@CasualDeveloper

Copy link
Copy Markdown
ContributorAuthor

Fork updated to sync with dev (as of cb1a500).

@lowlyocean

lowlyocean commented Apr 30, 2026

Copy link
Copy Markdown

Hey everyone, wondering what the latest is on this? Trying to have "Build" agent (with local model) default to enable_thinking: false , and there doesn't seem to be a way to configure that yet: #23995

Admit current Session agent and model selection atomically with each prompt, persist it through promotion, and regenerate the public clients.
Sign up for freeto 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.

[QUESTION] Agent default variant handling in TUI/Desktop (#7156)

7 participants

@CasualDeveloper@rekram1-node@iamhenry@mjakl@axsuul@lowlyocean