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.
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/edittools, or allowbashbut restrict it to a small allowlist likerg *andsed *. 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:
permissionobject via SDK when creating a session or sending a prompt (e.g.,session.createorsession.prompt).{ "permission": { "bash": { "*": "deny", "rg *": "allow", "sed *": "allow" } } }agent: "build"with a permission override for that run).Why:
Disclaimer: This feature request was drafted with the help of AI.