v2: root TUI no longer accepts --agent · Issue #56842 · anomalyco/opencode · GitHub
Skip to content

v2: root TUI no longer accepts --agent #56842

Open

Description

@ShreeMulay

Description

The V2 root command rejects --agent, although opencode mini and opencode run still accept it. V1 accepted this flag on the full-screen TUI.

This blocks wrappers from starting the normal TUI with a selected primary agent, such as Plan. The TUI already consumes args.agent; the root CLI does not expose or pass it.

This replaces #53728, which was reproduced but automatically closed because its body did not match the issue template. It is related to #56218 and the model-only fix in #48163.

My current workaround creates a Plan session through the API and attaches to it. Passing --agent through the root command would avoid that coupling.

OpenCode version

2.0.32

Steps to reproduce

  1. Run opencode --agent plan.
  2. Observe that the root command rejects the flag.
  3. Run opencode mini --agent plan and observe that the flag is accepted.

Operating System

Linux

Activity

  1. opencode-agent commented on Oct 18, 2026

    @opencode-agent
    Contributor

    Thanks for the clear report and for linking the earlier issues. You're right that the v2 root command has no --agent flag: in packages/cli/src/commands/commands.ts only run and mini define agent and model, but the TUI already reads args.agent, so the flag just never reaches it.

    I think this is a duplicate of #56218, which is still open and asks for both -m and --agent to work again on the root command, as they did in v1. Possible duplicates and related items, ordered by likelihood:

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different, for example if you'd like --agent tracked separately from #56218.

  2. ShreeMulay commented on Oct 18, 2026

    @ShreeMulay
    Author

    #56218 is primarily tracking --model, and its active implementation PR (#48163) is model-only. I would like to keep this issue as the linked bug for the independent --agent patch. I will keep that PR scoped to --agent and coordinate with #48163 so the two changes do not conflict.

  3. opencode-agent commented on Oct 18, 2026

    @opencode-agent
    Contributor

    Thanks, that makes sense. #56218 and its PR #48163 only add --model, so I'll keep this issue open separately, as the request for opencode --agent <name> to start the full-screen TUI with that primary agent, like mini and run already do. I've withdrawn the duplicate suggestion, so the bot won't close this issue.

    Maintainers will consider it. Related:

  4. chrisLytsoft commented on Oct 21, 2026

    @chrisLytsoft

    Confirming from our side: #57778 is a duplicate of this issue with the identical root cause (v2's top-level parser has no --agent; the v1 launch form dies in a bare ShowHelp ~3 ms after cli starting; the same flags still work on mini/run). Please treat #56842 as the canonical tracking issue for this bug from our side — we will not reply on #57778, so it can close as a duplicate of this issue.

    Adding the headless detail the triage on #57778 asked for, which I don't think is stated above yet:

    Headless silent-failure amplifier. Scheduled wrappers that launch opencode detached (Start-Process from a PowerShell Task Scheduler action) exit 0 regardless of the CLI failure, so the scheduler reports success (LastTaskResult 0) while nothing actually runs. Our case: after the npm v1→v2 upgrade on 2026-10-16, daily scheduled sessions failed silently from 2026-10-16 to 2026-10-21 — several days of automation "succeeding" while zero sessions were created. Detection required correlating session history against ~/.local/share/opencode/log/opencode.log (the run=… ShowHelp pair quoted on #57778); the exit codes and scheduler state were green throughout.

    Diagnostic gap suggestion. The bare ShowHelp failure names no flag — nothing distinguishes "you passed an unknown flag" from any other help output, which is exactly the case for headless callers. An "unknown flag: --agent"-style error message (or a non-zero, distinguishable exit code for argument-parse failures) would surface this entire class immediately instead of after days of silent failure.

    Workaround confirmed for headless use: opencode mini --agent <name> --prompt "<text>" launches and consumes the prompt correctly in the scheduled, detached context (verified with process, log, and session-record evidence).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions