Skip to content

[FEATURE]: SDK-level permission overrides for tools #5965

@ramarivera

Description

@ramarivera
  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

I want to programmatically constrain tool permissions per prompt/session when using the OpenCode SDK, without relying on an on-disk opencode.json.

Use case: In an SDK-driven pipeline, I need to allow only read/edit tools, or allow bash but restrict it to a small allowlist like rg * and sed *. Today, the SDK lets me toggle tools on/off, but command-level allowlists appear to only be read from server config (opencode.json / agent config). This makes it hard to enforce least privilege in transient or multi-tenant workflows where I can’t depend on a host file.

Requested behavior:

  • Allow passing a permission object via SDK when creating a session or sending a prompt (e.g., session.create or session.prompt).
  • Support the same schema used in opencode.json, including command allowlists for bash:
    {
      "permission": {
        "bash": {
          "*": "deny",
          "rg *": "allow",
          "sed *": "allow"
        }
      }
    }
  • Ideally allow per-agent overrides in the SDK call (e.g., agent: "build" with a permission override for that run).

Why:

  • Prevents runaway tool usage when running agents programmatically.
  • Enables safe, scoped automation without requiring a persistent config file on the server host.
  • Mirrors the existing config-driven permission model, but makes it available programmatically.

Disclaimer: This feature request was drafted with the help of AI.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions