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
{{ message }}
Repository navigation
PermissionDenied error echoes the entire effective bash ruleset into the tool result #53446
On a permission deny, opencode builds a PermissionDeniedError whose message embeds the entire effective permission.bash ruleset, not just the rule that matched. That message is stored on the tool part's state.error and replayed to the model on every subsequent request in the session.
With a large but legitimate policy, one denial can exceed the context window. With about 5,500 bash rules, a single denied compound command produced a ~384,000-character (~96k-token) error string. Session input jumped from ~32k to ~193k tokens in one turn, forcing repeated compactions. After compaction the agent re-read files, was denied again, and looped.
The denial happens before tool.execute.after, so a plugin can't cap it there. experimental.chat.messages.transform can rewrite state.error, which works as a local workaround, but the fix belongs upstream.
Related: #42437 (denial records pruned from context). Here, the denial's payload is itself the context hazard.
Plugins
No response
OpenCode version
1.18.34. Also observed on 1.18.16 at smaller scale; the echo size tracks the ruleset size, not the version.
Steps to reproduce
Steps to reproduce
Configure a permission.bash ruleset. Even a small one shows it: with 15 rules, the denial message contains all 17 effective rules.
Have an agent run a command its ruleset denies, e.g. a compound command where one segment isn't allowed.
Inspect the tool part: state.error reads "The user has specified a rule which prevents you from using this specific tool call. Here are some of the relevant rules [ … every rule … ]".
Send any next prompt. The full ruleset is replayed in the request.
Expected
The denial names only the matched rule and the denied command, e.g.
PermissionDenied: matched rule {"permission":"bash","pattern":"head *","action":"deny"} for command "…".
Actual
The entire effective ruleset is serialized into the tool result on every denial and replayed across requests. The cost grows linearly with policy size.
Suggested fix
Build the error from the single rule returned by the evaluator (the last matching rule) plus the command, optionally with a rule count, instead of serializing the full ruleset.
Screenshot and/or share link
No response
Operating System
Ubuntu latest LTS
Terminal
Reproduced headless via opencode serve; also occurs in the TUI.
Activity
github-actions commentedon Oct 5, 2026
This issue might be a duplicate of an existing issue. Please check:
thdxr commentedon Oct 11, 2026
Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (
opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊