Skip to content

fix: root-level permission config not being respected#14070

Open
bfirsh wants to merge 1 commit into
anomalyco:devfrom
bfirsh:fix/root-permission-config
Open

fix: root-level permission config not being respected#14070
bfirsh wants to merge 1 commit into
anomalyco:devfrom
bfirsh:fix/root-permission-config

Conversation

@bfirsh
Copy link
Copy Markdown

@bfirsh bfirsh commented Feb 18, 2026

Summary

Fixes #8832

Root-level permission config in opencode.json was being ignored. The same config worked when placed under agent.build.permission but not at the root.

Examples that didn't work

Setting permissions at the root level had no effect — bash commands would still be auto-allowed instead of prompting:

{
  "permission": {
    "*": "ask",
    "bash": {
      "*": "ask",
      "ls *": "allow"
    }
  }
}

Similarly, this config intended to require approval for all bash except ls, but all commands ran without asking:

{
  "permission": {
    "*": "allow",
    "bash": {
      "*": "ask",
      "git log *": "allow",
      "ls *": "allow"
    },
    "edit": "ask"
  }
}

Moving the exact same config under agent.build.permission worked fine.

Cause

When multiple config sources are merged via mergeDeep (e.g. global config + project config), JavaScript object key ordering is not guaranteed. The catch-all "*": "ask" key could end up after specific tool keys like "bash" in the merged object.

fromConfig iterates with Object.entries(), so the { permission: "*", pattern: "*", action: "ask" } rule would appear after { permission: "bash", pattern: "ls *", action: "allow" } in the ruleset. Since evaluate uses findLast, the wildcard * rule won over the specific bash rule.

Fix

In fromConfig, wildcard permission keys (like "*") are now always processed before specific tool keys. This ensures specific tool rules appear later in the ruleset and take precedence via findLast, regardless of the key ordering in the config object.

In fromConfig, wildcard permission keys like "*" could end up after
specific tool keys (like "bash") due to key reordering from mergeDeep
during config merging. Since evaluate uses findLast, the catch-all
"*" rule would win over the more specific tool rule.

Fix by sorting wildcard permission keys before specific keys in
fromConfig so specific tool rules always appear later and take
precedence.

Closes anomalyco#8832
@humb1t
Copy link
Copy Markdown

humb1t commented Apr 15, 2026

Thanks a lot for the fix Ben, can't wait till it will land!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

opencode not respecting permissions

2 participants