anomalyco / anomalyco/opencode

Config permissions/agents overrides cannot override built-in agent policies (external_directory always asks)

Open
#43,669 3 comments 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 20, 2026.

2.0
Dominant language
TypeScript
Stars
209k
Forks
27.5k
Avg merge
7h 2m
Merged PRs (30d)
384

Description

Summary

Config-based YOLO / auto-approve does not work in opencode2 beta: setting permissions (V2 array) and agents.<id>.permissions to allow does not override built-in agent policies, so external_directory access still requires approval (ask) even with an allow-all rule.

Environment

  • opencode version: 0.0.0-beta-17728
  • OS: Linux 7.0.0-29-generic (Ubuntu) x86_64
  • Terminal: TERM_PROGRAM=Orca TERM=xterm-256color COLORTERM=truecolor
  • Shell: /bin/bash
  • Install/channel: beta
  • Server: background service http://0.0.0.0:49374
  • Config: ~/.config/opencode/opencode.json

Reproduction

  1. Add the following to the global config:
{
  "$schema": "https://opencode.ai/config.json",
  "permissions": [{ "action": "*", "resource": "*", "effect": "allow" }],
  "agents": {
    "build": {
      "permissions": [{ "action": "external_directory", "resource": "*", "effect": "allow" }]
    }
  }
}
  1. Restart the server: opencode2 service restart
  2. Run: opencode2 run -m <model> "read /etc/hostname"
  3. Result: permission is still requested
! permission requested: external_directory (/etc/*); auto-rejecting
Read /etc/hostname failed
The user declined this tool call

Expected Behavior

An allow-all rule (global or per-agent) should allow all tool actions including external directory access, so no permission prompt appears.

Actual Behavior

External directory access still asks. The built-in external_directory: ask policy wins over the user's allow rules.

Root Cause Analysis

  1. The permissions array IS parsed: opencode2 debug agents shows {action: "*", resource: "*", effect: "allow"} at the start of every agent's effective permission array.
  2. V2 permission evaluation uses "last matching rule wins" (findLast). The built-in agent policy rule {external_directory, *, ask} appears AFTER the user's allow-all, so it wins and the request is rejected/asked.
  3. agents.<id>.permissions config overrides are NOT appended: debug agents output shows they are missing from the end of the built-in agents' permission arrays.
  4. Source: the agent builder reads cfg.agent (singular) but the config schema field is agents (plural), with no conversion — so JSON-configured agent overrides are ignored in this beta.

Suggested Fix

  • Convert the V2 agents field into the agent object used by the agent builder (packages/opencode/src/agent/agent.ts), or make the builder read the plural field
  • Or ensure user-specified agent rules are appended after built-in policies so they can override them

Workarounds

  • CLI: opencode2 run --auto / --yolo (client sends "once" for permission requests) — works
  • Web UI: click "Always allow" per project (manual)

Related known issues

  • #9661/#21119 Web Revert/Fork actions missing/broken over the versions (web client session/state issues)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.