Repository navigation
Description
Description
Summary
experimental.policies statements with "action": "permission" are silently dropped by the config validator in 2.0.26, even though the V2 policies documentation describes them as supported. This makes it impossible to express a hard-deny that overrides agent rules and saved approvals.
Environment
- opencode version: 2.0.26 (channel
latest) - OS: Microsoft Windows [Version 10.0.26300.9550] (win32 x64)
- Terminal:
TERM=xterm-256color,WT_SESSIONpresent (Windows Terminal) - Shell:
C:\WINDOWS\system32\cmd.exe - Install/channel: standalone binary, release channel
- Active plugins: none found in config
Expected Behavior
Both statements are retained. Per the V2 policies guide, the permission statement should hard-deny shell:git push, take precedence over agent permission rules and saved "Allow always" approvals, and fail the check with Blocked by configuration policy instead of prompting.
Actual Behavior
The permission statement is discarded and the array contains only the provider.use entry. A single WARN is written to the server log:
level=WARN message="configuration normalization diagnostic"
source="...\opencode.json" path=$.experimental.policies.1 kind=invalid
action="skipped malformed recognized value" role=server
The index in path corresponds to the position of the rejected statement.
Reducing the statement to a single permission entry yields an empty array:
{ "experimental": { "policies": [ { "action": "permission", "resource": "read:*.env", "effect": "deny" } ] } }"policies": []All three required fields are present and effect is valid, so only the action value is rejected.
Additional Context
The published schema agrees with the runtime and disagrees with the docs. In https://opencode.ai/config.json, $defs/ConfigV2.Experimental.Policy defines:
"action": { "anyOf": [ { "anyOf": [ { "type": "string", "enum": [ "provider.use" ] } ] } ] }"permission" is not an accepted value. This suggests the schema and the validator shipped before the permission action was implemented, while the guide was written against the intended behavior.
The documentation at https://opencode.ai/v2/docs/policies documents permission extensively, including:
- a dedicated "Permissions" section with a pattern table (
shell:*,read:*/.ssh/*,external_directory:*,subagent:general,github_delete_repository:*) - the
<action>:<value>resource syntax - the precedence claim that it "applies after agent rules and saved approvals, so it overrides an
askand an 'Allow always' approval alike" - an
allowstatement that lifts an earlier broaderdeny
Failure mode matters here. A user configuring a security policy gets a silently empty list and one WARN line, while the docs promise an unbreakable deny. This is reproduced consistently on every reload, not intermittently.
Workaround used: declare equivalent rules under agents.<id>.permissions, which are appended after the base policy and therefore override the built-in ask on sensitive reads. This works for global agents but cannot express "overrides a saved approval", which is the specific guarantee the documentation advertises.
Related: the same guide states provider.use replaces the V1 enabled_providers / disabled_providers fields. Those V1 fields are still accepted by the schema, which is the reverse of the documented situation.
Plugins
No response
OpenCode version
2.0.26
Steps to reproduce
Reproduction
- Create
opencode.jsonin any project directory:
{
"$schema": "https://opencode.ai/config.json",
"experimental": {
"policies": [
{ "action": "provider.use", "resource": "openai", "effect": "deny" },
{ "action": "permission", "resource": "shell:git push *", "effect": "deny" }
]
}
}- Run
opencode reloador any command that loads configuration. - Run
opencode debug configand inspectexperimental.policies.
Screenshot and/or share link
No response
Operating System
Windows 11
Terminal
Windows Terminal
Activity
opencode-agent commentedon Oct 9, 2026
Thanks for the detailed report. I can confirm it on 2.0.26, and it still happens on the latest
v2(8eff035).With your
opencode.json,opencode debug configshows only theprovider.useentry underexperimental.policies. The"action": "permission"statement is dropped.The cause is that the docs and the code use different names for the same action. The config schema only accepts the actions
provider.use,tool.useandintegration.use. The hard-deny hook that checks permissions matches ontool.use, while the policies guide calls that actionpermission. The script below loads a config withprovider.use,permissionandtool.useentries. Only thepermissionone is dropped, and thetool.useentry (sameshell:git push *resource) is kept.Until the docs and the code agree,
"action": "tool.use"with the same<action>:<pattern>resource looks like the intended way to get this deny. I've only confirmed that it survives config loading; I haven't tested that it actually blocks a call.Reproduction script (repro.sh)
Run it:
bash repro.shMcKollen commentedon Oct 9, 2026
Confirmed empirically that
tool.useis wired to the same hard-deny hook the guide callspermission, and that it overrides agent permission rules. Closing the open question from the bot's comment ("I've only confirmed that it survives config loading; I haven't tested that it actually blocks a call").Tested on 2.0.26, Windows 11, standalone binary.
Setup
Isolated project,
secrets.envcontaining a decoy value. Three runs differing only in config.Run 1 — agent deny, no policy
Run 2 — agent allow,
tool.usedenyThe agent rule explicitly allows the read, and the deny still wins. The error string differs from run 1, which is what distinguishes a policy denial from the ordinary permission check.
Run 3 — agent allow, no policy (control)
The file was read and its contents returned. This confirms runs 1 and 2 are not false positives: the same tool call with the same
allowreads the file when no policy is present.Config loading
All three accepted action values survive
opencode debug config;permissionalone is dropped:opencode debug configreturns the first three entries and omits the fourth, with one WARN at$.experimental.policies.3.Conclusion
tool.useis the working name for the documentedpermissionaction.integration.usealso loads. Since the only defect is the name mismatch between the schema and the guide, renaming the action in the docs totool.use(or addingpermissionas an alias) resolves it.The practical impact is larger than a naming inconsistency. Because global policies outrank project configuration, a
tool.usedeny cannot be re-enabled by a repository, whereas an equivalent rule underagents.<id>.permissionscan be overridden by a project-levelopencode.json. Users relying on the documentedpermissionname for secrets protection get no protection at all and are silently downgraded to the built-inask, which an "Allow always" in the TUI lifts permanently.I have migrated my global config to
tool.useaccordingly.cc-bb-aa commentedon Oct 10, 2026
Silently dropping a policy statement is the worst failure mode for a permission system, since the user believes a rule exists that does not. The validator should reject unknown actions loudly instead of skipping them. A test that round trips every documented action type would catch this whole class.
neriousy commentedon Oct 20, 2026
Fixed by #55259: the policy docs now use
tool.use(the action the schema and the hard-deny hook support) instead ofpermission, and they list all three supported actions. Usingtool.use, as you already confirmed, is the intended way to do this. If something still doesn't match the docs, comment and we'll reopen.