You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Run opencode --agent plan.
Observe that the root command rejects the flag.
Run opencode mini --agent plan and observe that the flag is accepted.
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.
#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.
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.
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).
Activity
opencode-agent commentedon Oct 18, 2026
Thanks for the clear report and for linking the earlier issues. You're right that the v2 root command has no
--agentflag: inpackages/cli/src/commands/commands.tsonlyrunandminidefineagentandmodel, but the TUI already readsargs.agent, so the flag just never reaches it.I think this is a duplicate of #56218, which is still open and asks for both
-mand--agentto work again on the root command, as they did in v1. Possible duplicates and related items, ordered by likelihood:opencode -m provider/modelno longer accepted on root command (worked in v1) #56218: open request to restore-m/--modeland--agenton the root TUI command--agentflag (reproduced, then closed automatically because of the template)--modelto the root command;--agentwould need the same small change, and you've already asked there about combining themThe 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
--agenttracked separately from #56218.ShreeMulay commentedon Oct 18, 2026
#56218is 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--agentpatch. I will keep that PR scoped to--agentand coordinate with #48163 so the two changes do not conflict.opencode-agent commentedon Oct 18, 2026
Thanks, that makes sense. #56218 and its PR #48163 only add
--model, so I'll keep this issue open separately, as the request foropencode --agent <name>to start the full-screen TUI with that primary agent, likeminiandrunalready do. I've withdrawn the duplicate suggestion, so the bot won't close this issue.Maintainers will consider it. Related:
opencode -m provider/modelno longer accepted on root command (worked in v1) #56218: same request for-m/--modelon the root command--modelto the root command; an--agentchange would touch the same root command options--agentflag, reproduced on v2.0.20chrisLytsoft commentedon Oct 21, 2026
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 bareShowHelp~3 ms aftercli starting; the same flags still work onmini/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-Processfrom 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(therun=…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).