Skip to content

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

Open
CasualDeveloper wants to merge 1 commit intoanomalyco:devfrom
CasualDeveloper:feat/7138-agent-default-variant
Open

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

Conversation

@CasualDeveloper
Copy link
Copy Markdown
Contributor

@CasualDeveloper CasualDeveloper commented Jan 7, 2026

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

github-actions Bot commented Jan 7, 2026

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 CasualDeveloper force-pushed the feat/7138-agent-default-variant branch 3 times, most recently from 11edba0 to 9cc62c8 Compare January 8, 2026 05:59
@CasualDeveloper CasualDeveloper marked this pull request as ready for review January 8, 2026 05:59
@CasualDeveloper CasualDeveloper force-pushed the feat/7138-agent-default-variant branch from 9cc62c8 to ae2dd3e Compare January 8, 2026 06:14
@CasualDeveloper
Copy link
Copy Markdown
Contributor Author

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!

@CasualDeveloper CasualDeveloper 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
@CasualDeveloper CasualDeveloper 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
@CasualDeveloper CasualDeveloper 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 CasualDeveloper force-pushed the feat/7138-agent-default-variant branch 5 times, most recently from 07c8bd5 to 065875f Compare January 11, 2026 14:31
@CasualDeveloper CasualDeveloper force-pushed the feat/7138-agent-default-variant branch from 065875f to 6088a6f Compare January 11, 2026 18:51
@CasualDeveloper CasualDeveloper force-pushed the feat/7138-agent-default-variant branch 8 times, most recently from 2e9637c to d415762 Compare January 14, 2026 20:39
Comment thread packages/opencode/src/session/llm.ts Outdated
Comment thread packages/opencode/src/cli/cmd/tui/context/local.tsx Outdated
@CasualDeveloper CasualDeveloper force-pushed the feat/7138-agent-default-variant branch from 2abcbe0 to 0cc306d Compare February 12, 2026 13:24
@CasualDeveloper
Copy link
Copy Markdown
Contributor Author

CasualDeveloper commented Feb 12, 2026

@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.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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
File Description
packages/opencode/test/cli/tui/model-variant.test.ts Adds unit coverage for variant resolution/cycling semantics in the TUI.
packages/opencode/test/agent/agent.test.ts Verifies agent variant is loaded from config and defaults to undefined.
packages/opencode/src/cli/cmd/tui/context/model-variant.ts Adds helper functions for configured-variant matching and variant resolution/cycling.
packages/opencode/src/cli/cmd/tui/context/local.tsx Wires configured + selected variant resolution into the TUI local model context.
packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx Initializes local agent/model/variant from the last user message; shows effective variant in prompt bar.
packages/app/src/context/model-variant.ts Updates Desktop cycling logic (no longer advances from configured variant).
packages/app/src/context/model-variant.test.ts Updates/adds tests to match the new Desktop cycling behavior.
packages/app/src/context/local.tsx Adds effective() alias for variant display parity.
.opencode/agent/triage.md Sets triage agent default variant: "high".

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

Comment thread packages/opencode/src/cli/cmd/tui/context/local.tsx Outdated
Comment thread packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx Outdated
Comment thread packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx Outdated
@CasualDeveloper
Copy link
Copy Markdown
Contributor Author

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

@lowlyocean
Copy link
Copy Markdown

lowlyocean commented Apr 30, 2026

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

- Resolve configured variants through shared helpers used by app and TUI
- Respect agent-configured variants unless the user selects an override or Default
- Restore and hydrate TUI variant state without stale overrides or legacy default sentinels
- Add variant tests for shared helpers and agent config

Closes anomalyco#22065
Sign up for free to 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