fix(cli): pass --agent through to TUI by ShreeMulay · Pull Request #56848 · anomalyco/opencode · GitHub
Skip to content

fix(cli): pass --agent through to TUI - #56848

Open
ShreeMulay wants to merge 1 commit into
anomalyco:devfrom
ShreeMulay:root-agent-flag
Open

ShreeMulay wants to merge 1 commit into
anomalyco:devfrom
ShreeMulay:root-agent-flag

Conversation

@ShreeMulay

@ShreeMulay ShreeMulay commented Oct 18, 2026 •

Copy link
Copy Markdown

Issue for this PR

Closes #56842

Type of change

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

What does this PR do?

Adds --agent <name> to the root opencode command and passes it to the full-screen TUI.

The TUI now waits for the launch location's agents before applying the CLI selection. That avoids falsely rejecting a valid agent during startup. Only a validated primary agent can override a resumed session's saved agent; invalid, hidden, and subagent names keep the existing warning.

How did you verify your code works?

  • CLI parser tests, repeated 10 times
  • Focused TUI startup and selection tests, repeated 10 times
  • Full TUI suite: 1,499 passed, 2 skipped, 0 failed
  • CLI and TUI typechecks
  • Root bun run check: 34/34 tasks passed
  • Live TUI: --agent plan selected Plan without a false warning; an unknown name showed the existing warning

Screenshots / recordings

Not included. This changes startup selection behavior without changing the interface layout.

Checklist

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

Added by the opencode bot (AI-generated).

Related: #56218, #45573

Public API: adds the --agent <name> flag to the root opencode command (backwards compatible)

Agent-Session: ses_02af8789bffeFnT0FL166url19
@github-actions

Copy link
Copy Markdown
Contributor

@opencode-agent opencode-agent Bot 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.

This looks good to me. On the base, opencode --agent plan isn't accepted: it prints the usage text and never starts. With this change, --agent plan opens the TUI with Plan selected and no warning, and an unknown name shows the usual Agent not found toast. I checked this by running both checkouts from source and driving the TUI with the simulated model. The new CLI and TUI tests pass, and the new TUI tests fail against the base source. CLI and TUI typechecks pass.

Public API: adds an optional --agent <name> flag to the root opencode command (backwards compatible). Nothing else outside the code changes.

The flag is checked once, after the launch directory's agents have loaded, so a valid name isn't wrongly rejected at startup. It outranks a session's saved agent the same way args.agent already did. Hidden primary agents are still rejected, which matches how the TUI already works (#45573 asks to change that separately). Your branch and #48163 (--model) edit the same spot in the root flags and the handler's TUI args, so whichever lands second will need a small rebase. No blocking concerns.

Related: #56218, #45573

This branch has not been deployed

No deployments
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.

v2: root TUI no longer accepts --agent

1 participant