Skip to content

config: experimental.policies silently drops "permission" action statements #54214

Closed

Description

@McKollen

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_SESSION present (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 ask and an 'Allow always' approval alike"
  • an allow statement that lifts an earlier broader deny

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

  1. Create opencode.json in 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" }
    ]
  }
}
  1. Run opencode reload or any command that loads configuration.
  2. Run opencode debug config and inspect experimental.policies.

Screenshot and/or share link

No response

Operating System

Windows 11

Terminal

Windows Terminal

Activity

  1. opencode-agent commented on Oct 9, 2026

    @opencode-agent
    Contributor

    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 config shows only the provider.use entry under experimental.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.use and integration.use. The hard-deny hook that checks permissions matches on tool.use, while the policies guide calls that action permission. The script below loads a config with provider.use, permission and tool.use entries. Only the permission one is dropped, and the tool.use entry (same shell: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)
    #!/usr/bin/env bash
    # Reproduces #54214: "permission" policy statements are dropped; "tool.use" is kept.
    # Usage: OPENCODE="opencode" bash repro.sh   (or set OPENCODE to a from-source command)
    set -u
    OPENCODE=${OPENCODE:-opencode}
    dir=$(mktemp -d); cd "$dir"
    cat > opencode.json <<'JSON'
    {
      "$schema": "https://opencode.ai/config.json",
      "experimental": {
        "policies": [
          { "action": "provider.use", "resource": "openai", "effect": "deny" },
          { "action": "permission", "resource": "shell:git push *", "effect": "deny" },
          { "action": "tool.use", "resource": "shell:git push *", "effect": "deny" }
        ]
      }
    }
    JSON
    $OPENCODE --version
    echo "--- experimental.policies as loaded (input had provider.use, permission, tool.use):"
    $OPENCODE debug config 2>&1 | grep -A20 '"policies"' | sed '/^ *\]/q'

    Run it: bash repro.sh

  2. McKollen commented on Oct 9, 2026

    @McKollen
    Author

    Confirmed empirically that tool.use is wired to the same hard-deny hook the guide calls permission, 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.env containing a decoy value. Three runs differing only in config.

    Run 1 — agent deny, no policy

    "agents": {
      "build": {
        "permissions": [
          { "action": "read", "resource": "*.env", "effect": "deny" }
        ]
      }
    }
    Error: Permission denied: read
    

    Run 2 — agent allow, tool.use deny

    "agents": {
      "build": {
        "permissions": [{ "action": "read", "resource": "*", "effect": "allow" }]
      }
    },
    "experimental": {
      "policies": [
        { "action": "tool.use", "resource": "read:*.env", "effect": "deny" }
      ]
    }
    Error: Blocked by configuration policy
    

    The 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)

    "agents": {
      "build": {
        "permissions": [{ "action": "read", "resource": "*", "effect": "allow" }]
      ]
    }

    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 allow reads the file when no policy is present.

    Config loading

    All three accepted action values survive opencode debug config; permission alone is dropped:

    "experimental": {
      "policies": [
        { "action": "tool.use", "resource": "read:*.env", "effect": "deny" },
        { "action": "tool.use", "resource": "shell:git push *", "effect": "deny" },
        { "action": "integration.use", "resource": "*", "effect": "deny" },
        { "action": "permission", "resource": "read:*.env", "effect": "deny" }
      ]
    }

    opencode debug config returns the first three entries and omits the fourth, with one WARN at $.experimental.policies.3.

    Conclusion

    tool.use is the working name for the documented permission action. integration.use also loads. Since the only defect is the name mismatch between the schema and the guide, renaming the action in the docs to tool.use (or adding permission as an alias) resolves it.

    The practical impact is larger than a naming inconsistency. Because global policies outrank project configuration, a tool.use deny cannot be re-enabled by a repository, whereas an equivalent rule under agents.<id>.permissions can be overridden by a project-level opencode.json. Users relying on the documented permission name for secrets protection get no protection at all and are silently downgraded to the built-in ask, which an "Allow always" in the TUI lifts permanently.

    I have migrated my global config to tool.use accordingly.

  3. cc-bb-aa commented on Oct 10, 2026

    @cc-bb-aa

    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.

  4. neriousy commented on Oct 20, 2026

    @neriousy
    Member

    Fixed by #55259: the policy docs now use tool.use (the action the schema and the hard-deny hook support) instead of permission, and they list all three supported actions. Using tool.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.

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions