Skip to content

fix(github): auto-deny permissions and emit events in non-interactive mode#6832

Open
elithrar wants to merge 7 commits intoanomalyco:devfrom
elithrar:non-interactive-events-deny
Open

fix(github): auto-deny permissions and emit events in non-interactive mode#6832
elithrar wants to merge 7 commits intoanomalyco:devfrom
elithrar:non-interactive-events-deny

Conversation

@elithrar
Copy link
Contributor

@elithrar elithrar commented Jan 4, 2026

Fixes issues where permissions requests block indefinitely in CI/GitHub Actions, with no output indicating why. I keep running into this in CI runs, especially when the harness is trying to solve a problem or I'm testing/building plugins.

Since there's no way to prompt a user, it should just auto-deny by default + emit this to the logs so users can understand what happened.

Changes

  • Add isInteractive() utility - checks CI env var, OPENCODE_CLIENT, and TTY state
  • Auto-deny permission requests when !isInteractive() (no one to approve)
  • Emit permission.asked events before denying so they're visible in logs
  • Subscribe to permission events in github.ts and run.ts with actionable guidance on how to allow
  • Add OPENCODE_EMIT_SUBAGENT_EVENTS flag for verbose subagent output in CI
  • Add emit_subagent_events input to GitHub Action
  • Deny question permission by default in GitHub Action sessions (merged from dev)

isInteractive() Logic

Only auto-denies for the CLI client in non-TTY/CI environments:

  1. OPENCODE_FORCE_INTERACTIVE=true → interactive (for tests)
  2. CI=true → non-interactive (auto-deny)
  3. OPENCODE_CLIENT is not cli (e.g. desktop) → interactive (GUI handles permissions)
  4. Otherwise, check stdin.isTTY && stdout.isTTY

current possible OPENCODE_CLIENT values: cli (default), desktop

Example Output

When a permission is denied in CI:

| Denied  external_directory: /tmp/opencode-source
  To allow, add to opencode.json: { "permission": { "external_directory": "allow" } }

@github-actions
Copy link
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@elithrar elithrar closed this Jan 27, 2026
@elithrar elithrar reopened this Feb 14, 2026
@elithrar elithrar changed the title fix: auto-deny permissions and emit events in non-interactive mode fix(github): auto-deny permissions and emit events in non-interactive mode Feb 14, 2026
- Add isInteractive() utility to detect CI/non-TTY environments
- Auto-deny permission requests when running non-interactively
- Emit permission.asked events before denying for visibility
- Subscribe to permission events in github.ts and run.ts with actionable guidance
- Add OPENCODE_EMIT_SUBAGENT_EVENTS flag for verbose subagent output
- Add emit_subagent_events input to GitHub Action
GUI clients like the desktop app handle permissions through their own UI,
so we should not auto-deny when OPENCODE_CLIENT is set to something other
than 'cli'.
- Fix unsubscribeEvents shadowing bug in github.ts (cleanup was never called)
- Make CI env var check case-insensitive (CI=TRUE now works)
- Use bracket notation for env var access (codebase consistency)
- Add unit tests for isInteractive() covering all code paths
@elithrar elithrar force-pushed the non-interactive-events-deny branch from d6b2f38 to 1b409da Compare February 14, 2026 12:41
@elithrar
Copy link
Contributor Author

elithrar commented Feb 14, 2026

@rekram1-node wanted to bring this one back: getting more info in CI when 'headless' is hugely useful to us.

right now any subagents are invisible, and any permissions errors just stall the workflows.

also applies to sandbox environments - setting OPENCODE_EMIT_SUBAGENT_EVENTS allows us to capture and emit those + any questions asked.

@elithrar
Copy link
Contributor Author

another example: https://github.com/ask-bonk/ask-bonk/actions/runs/22177421690/job/64129579673#step:3:281

(it’s hard to debug as it just stalls forever - it shouldn’t prompt for questions when non-interactive)

@elithrar
Copy link
Contributor Author

updated and resolved conflicts

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants