[FEATURE]: Add non-interactive mode to "opencode run" #7457

Closed
opened 2026-02-16 18:07:13 -05:00 by yindo · 2 comments
Owner

Originally created by @smola on GitHub (Jan 24, 2026).

Originally assigned to: @thdxr on GitHub.

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Description

Add a non-interactive mode (e.g. --non-interactive) to opencode run. In this mode, opencode will never await for user input. Some choices will need to be made about how to react to expected input, but whatever these are, in this mode the command will eventually finish without ever expecting user input.

Use case

I'm using opencode run --format json to run opencode from non-interactive scripts. In this case, for a benchmark. I have a permission policy that I want to be respected. Once the run finishes, my script would inspect all tool calls that were made (or attempted).

Behavior details

  • It seems the main (or only?) thing that expects user input is permissions. So in non-interactive mode, a permission question should resolve to either reject or just abort the session. I think aborting and erroring out would probably make the most sense, and make this feature orthogonal to other proposed features for opencode run. In non-interactive mode, a permission question should just abort the session and exit the command. If someone wants the behavior to be answering allow/deny, that can be handled via explicit permissions.
  • If the output is not a TTY, then this mode should be enabled by default. It's better to let the user deal with a clear error, than letting a process hanging up indefinitely.

Related issues

Originally created by @smola on GitHub (Jan 24, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] I have verified this feature I'm about to request hasn't been suggested before. ### Describe the enhancement you want to request ## Description Add a non-interactive mode (e.g. `--non-interactive`) to `opencode run`. In this mode, opencode will never await for user input. Some choices will need to be made about how to react to expected input, but whatever these are, in this mode the command will eventually finish without ever expecting user input. ## Use case I'm using `opencode run --format json` to run opencode from non-interactive scripts. In this case, for a benchmark. I have a permission policy that I want to be respected. Once the run finishes, my script would inspect all tool calls that were made (or attempted). ## Behavior details - It seems the main (or only?) thing that expects user input is permissions. ~So in non-interactive mode, a permission question should resolve to either `reject` or just abort the session. I think aborting and erroring out would probably make the most sense, and make this feature orthogonal to other proposed features for `opencode run`.~ In non-interactive mode, a permission question should just abort the session and exit the command. If someone wants the behavior to be answering `allow`/`deny`, that can be handled via explicit permissions. - If the output is not a TTY, then this mode should be enabled by default. It's better to let the user deal with a clear error, than letting a process hanging up indefinitely. ## Related issues - https://github.com/anomalyco/opencode/issues/5888 is an example of someone hitting this issue in CI, getting their CI process to hang up. While the comments there proposing changing all permissions to either allow/deny are fair as a follow up solution, they do not address the fact that `opencode run` unexpectedly hangs up waiting for an input that will never come. - https://github.com/anomalyco/opencode/issues/11891 another user who could have used an error message instead an indefinite freeze - https://github.com/anomalyco/opencode/issues/9386 possibly the best way in many case to fix a workflow that gets hanged up on permission issues - https://github.com/anomalyco/opencode/issues/8463 also possibly useful when the preferred way to deal with permissions is allowing everything, but perhaps also achievable with `--tools '*'`.
yindo added the discussion label 2026-02-16 18:07:13 -05:00
yindo closed this issue 2026-02-16 18:07:13 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 24, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #5888: Opencode Hangs when used as CLI tool - Reports hanging when running as CLI with permission requests blocking indefinitely
  • #8203: opencode run hangs forever on API errors (breaks CLI/automation integrations) - Related issue where opencode run doesn't fail fast or handle errors properly in non-interactive contexts

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 24, 2026): This issue might be a duplicate of existing issues. Please check: - #5888: Opencode Hangs when used as CLI tool - Reports hanging when running as CLI with permission requests blocking indefinitely - #8203: opencode run hangs forever on API errors (breaks CLI/automation integrations) - Related issue where opencode run doesn't fail fast or handle errors properly in non-interactive contexts Feel free to ignore if none of these address your specific case.
Author
Owner

@smola commented on GitHub (Feb 14, 2026):

This was fixed by https://github.com/anomalyco/opencode/pull/11814. Now opencode run auto-rejects tool calls if they would lead to a permission prompt. Making opencode run always non-interactive. Closing.

@smola commented on GitHub (Feb 14, 2026): This was fixed by https://github.com/anomalyco/opencode/pull/11814. Now `opencode run` auto-rejects tool calls if they would lead to a permission prompt. Making `opencode run` always non-interactive. Closing.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#7457