Skip to content

feat(tui): assign model to specific agent via Ctrl+E#24317

Open
MrRobotoGit wants to merge 3 commits intoanomalyco:devfrom
MrRobotoGit:feat-agent-model-config
Open

feat(tui): assign model to specific agent via Ctrl+E#24317
MrRobotoGit wants to merge 3 commits intoanomalyco:devfrom
MrRobotoGit:feat-agent-model-config

Conversation

@MrRobotoGit
Copy link
Copy Markdown

@MrRobotoGit MrRobotoGit commented Apr 25, 2026

Issue for this PR

Closes #

Type of change

  • New feature

What does this PR do?

It allows users to assign specific models to primary agents and subagents directly from the TUI without manually editing opencode.json.

Previously, you had to edit the JSON config to assign a specific model to an agent (e.g., using deepseek-v4-pro for plan and qwen-3.5-plus for code_analyzer).

With this PR:

  1. The agent dialog (/agents) now displays the assigned model under each agent's name.
  2. Pressing Ctrl+E on an agent opens the model picker to assign a model to that specific agent.
  3. The selection is automatically persisted to opencode.json using jsonc-parser to preserve comments and formatting.
  4. If an agent has no explicit config, its last-used model is persisted to ~/.opencode/state/model.json.
  5. Built-in background subagents (explore, general, translator) are hidden from the manual assignment list to reduce clutter.

I noticed PR #17570 exists, but this implementation focuses specifically on the TUI experience (Ctrl+E keybind) and automatic config persistence.

How did you verify your code works?

  • Tested locally by running bun run dev
  • Opened the /agents dialog and verified the models are displayed correctly.
  • Pressed Ctrl+E on the code_analyzer subagent, selected a different model, and verified opencode.json was updated correctly without losing its JSONC formatting.
  • Restarted the application and verified the model selection persisted.
  • Verified that explore and general do not appear in the assignment list.
  • Ran bun typecheck with no errors.

Screenshots / recordings

Screenshot 2026-04-25 alle 19 04 36

Checklist

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

Users can now configure the model for specific primary or subagents directly from the Agent selection dialog without manually editing opencode.json.

- Show assigned model in agent descriptions
- Add Ctrl+E shortcut to dialog-agent to edit model
- Modify dialog-model to support assignToAgent mode
- Persist per-agent model configurations to config.json preserving JSONC format
- Persist last-used model per agent to state
- Hide built-in background subagents from assignment list
@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Apr 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

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

Based on my search, I found one potentially related PR:

Related PR Found:

The current PR (24317) appears to be a new or updated implementation of model assignment functionality with a focus on the Ctrl+E keybind and TUI integration. PR #17570 might be a predecessor, alternative approach, or related feature that should be reviewed for potential conflicts or duplication.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Apr 25, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

MrRobotoGit and others added 2 commits April 25, 2026 18:57
…ction

Read from modelStore instead of static agent data so the agent list
reflects the newly selected model immediately without reopening the menu.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… lacks vision support

When a user pastes an image into the chat and the selected model does not
support image input, automatically find a vision-capable model from any
available provider, use it to describe the image(s), and inject the
description as text before the main model processes the request.

- Add `vision_model` config field to pin a specific vision model
- Add `Provider.getVisionModel()` that scans all providers (skipping the
  current model) for one with `capabilities.input.image`
- Add vision fallback logic in `LLM.run()` with full error handling so
  failures degrade gracefully without breaking the main stream

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@MrRobotoGit
Copy link
Copy Markdown
Author

For maintainers — comparison with PR #17570 (also open, addresses a related goal):

#17570 (VenTheZone, Mar 15) #24317 (this PR)
Scope Subagents only Primary agents and subagents
Storage New subagent_model_assignments config field Writes per-agent model directly into opencode.json via jsonc-parser (preserves comments / formatting)
UX /assign-model slash command + dedicated dialog Ctrl+E on the existing /agents dialog
Granularity Global + project-specific (project overrides global) Per-agent in opencode.json, with last-used fallback in ~/.opencode/state/model.json for agents without explicit config
Surface TUI + desktop (packages/app) + tests TUI only, no desktop, no automated tests
Size +928 / −18, new SDK type +212 / −11, no SDK regen
File overlap only packages/opencode/src/config/config.ts

Both PRs solve "assign a specific model to an agent", but they're structurally independent — only config/config.ts overlaps, so neither blocks the other mechanically.

If only one approach should land, I think the trade-off is:

Happy to align with whatever direction the team prefers — including reworking this on top of #17570 if you'd rather take that one and extend it to primary agents, or closing this if there's a clear preference.

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.

1 participant