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
Permission denied messages should clearly name the matched deny rule #51046
When a command is blocked by a deny rule in opencode.json, the agent only receives a generic Permission denied: shell message. This makes it hard for the agent (and the user) to understand why the command was rejected, leading the agent to retry the same failing command or draw incorrect conclusions.
Reproduction
Add a deny rule to opencode.json, e.g.:
{
"permissions": {
"npm *": "deny"
}
}
Ask the agent to run a command such as npm install.
Observe the response returned to the agent.
Actual behavior
The agent only sees:
Permission denied: shell
There is no information about which rule caused the denial.
Expected behavior
The denial message should clearly state that execution was blocked because the command matched a deny rule, and include the matched pattern. For example:
(Or similar wording that surfaces the offending rule, e.g. denied by rule "npm *".)
Why this matters
Without an explicit reason, the agent cannot distinguish between:
"this command is forbidden by policy", vs.
"the shell tool is unavailable / misconfigured".
As a result, the agent may repeatedly attempt the blocked command, try alternate (still-blocked) invocations, or incorrectly conclude that an environment/tooling problem exists rather than a policy restriction. A precise message lets the agent adapt (e.g. pick a different, allowed approach) instead of looping on errors.
Suspected source
The relevant logic appears to live in packages/core/src/permission.ts, where the deny/allow decision is made and the error message is produced. The error returned there should be enriched with the matched rule pattern.
Suggestion
When a deny rule matches, include in the returned error:
the denied pattern (e.g. npm *),
optionally the tool/permission key that was checked,
a short hint that this is a policy denial rather than a tooling failure.
This keeps the message machine-readable (so agents can branch on it) while remaining human-readable.
I'd like to work on this issue.
I'll update the permission denial message to include the matched deny rule, respecting the existing rule precedence and preserving any custom denial reason. I'll keep the change focused on error reporting and add regression tests for overlapping rules, multiple resources, and custom reasons.
Activity
zonemeen commentedon Sep 24, 2026
I'd like to work on this issue.
I'll update the permission denial message to include the matched deny rule, respecting the existing rule precedence and preserving any custom denial reason. I'll keep the change focused on error reporting and add regression tests for overlapping rules, multiple resources, and custom reasons.
Tarquinen commentedon Oct 20, 2026
We're tracking this in #44521, so I'm closing this as a duplicate. Please follow that issue for updates.
— from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊