OpenCode Permissions and Hooks Reference
Just want the answer? Add the plugin and a permission block to opencode.json. The block is what sends tool calls to the plugin's main hook:
{
"$schema": "https://opencode.ai/config.json",
"plugin": ["acp-opencode"],
"permission": {
"bash": "ask",
"edit": "ask",
"webfetch": "ask"
}
}
OpenCode 2.0 (15 Oct 2026): the 2.0 train replaces this plugin API. permission.ask and tool.execute.* do not exist in 2.0, and a 1.x plugin loads as nothing while model calls still look priced. Everything below was checked against 1.18.4 and still describes what ships as latest (1.19.0). The 2.0 contract, the old-to-new hook map and a two-line check are in OpenCode 2.0 rewrites the plugin API.
Opencode has a permission system with allow, ask and deny verdicts. It also has plugins that run inside the process. That lets ACP sit directly on top of the permission system instead of beside it. This page covers how a verdict gets resolved, what each of the plugin’s two hooks sees, what you lose if you skip the config, and what runs with no credential. For every key in the permission block, see the opencode permissions reference.
The permission block resolves first
Opencode checks every tool call against the permission block in opencode.json before anything else. The verdicts are allow, deny and ask. The last matching rule wins. So a broad "bash": "ask" followed by a narrower "git status*": "allow" quiets the safe case and keeps the prompt for everything else.
Most tools default to allow. Two default to ask: external_directory (paths outside the project) and doom_loop (the same call three times with identical input).
This matters for plugins. Opencode gives a plugin one way to step into the approval itself, the permission.ask hook. It only fires for a call that already resolved to "ask". A tool set to allow never reaches it.
The two hooks that decide
acp-opencode registers four hooks. Two make decisions.
| Hook | What it does |
|---|---|
permission.ask |
Sends the call to /govern/tool-use. If ACP says allow, the permission is set to allow and the native prompt is skipped. If ACP says deny, the call is blocked. If ACP says ask, the plugin leaves it alone, so opencode’s own once / always / reject prompt appears as it would with no plugin. |
tool.execute.before |
A deny-only backstop for calls that never reach permission.ask, meaning anything set to allow. An ACP deny here throws [ACP] Denied by policy: <reason>, which is how opencode blocks a call from this hook. It also stores the call’s arguments and start time by callID for the audit row. |
The other two don’t decide anything. tool.execute.after posts the tool’s output to /govern/tool-output for the audit trail (capped at 200 KB, sent without waiting for a reply). chat.headers stamps X-GS-Session and X-GS-Client on every model request, which ties a session’s tool calls to its model spend in the cost view.
If both tool.execute.before and permission.ask fire for the same callID, which happens whenever a tool is set to ask, the plugin fetches the decision once and uses it for both.
Why you need the permission block
Leave a tool at its default allow and permission.ask never fires for it. There is no native prompt to step into. What’s left is the tool.execute.before backstop, which can only deny. An ACP allow has no prompt to skip. An ACP ask has nowhere to go, because only permission.ask can open opencode’s prompt.
So without the block you still get the audit and policy denies. You lose pre-approval and the ask prompt. The installer fills in bash, edit and webfetch entries if they’re missing, and it never overrides a choice you made yourself.
The native prompt, and what --auto does to it
When a tool resolves to ask, you get three answers. The middle one, always, approves that kind of call for the rest of the session. It’s handy, and it quietly turns ask into allow with no record outside opencode. The ACP audit row for the call that triggered it is the more durable record.
Opencode’s full-auto flag, --auto, skips the ask prompts. Explicit deny rules, from your permission block or from the plugin, still hold. So anything gated only by ask acts like allow under --auto, because nobody is there to answer. If a rule has to hold while you’re away, make it a deny. That goes for rules routed through the plugin too.
With no credential
With no ACP_BEARER_TOKEN and no ~/.acp/credentials, the published plugin (acp-opencode 0.2.1) makes no policy decisions. Both hooks return early and opencode behaves as if the plugin weren’t installed. There is no on-device decision mode for opencode today. The installer’s --local flag detects opencode and skips it, and says so.
Metering does run with no credentials. The plugin listens to opencode’s event bus and records every model call’s tokens and cost, and every tool result, to SQLite at ~/.acp/opencode-local.db. Read it with npx acp-opencode report. It never needs an account and never leaves the machine. The cost tracking reference covers it.
When ACP is unreachable
For the cloud path, network errors, timeouts over 2 seconds, non-2xx responses and malformed bodies all fail open by default. The tool call goes ahead, with one loud warning per session. To fail closed instead, set export ACP_FAIL_MODE=closed.
Don’t assume that setting covers every harness. The shared hook that Cursor, Codex and other installer-based harnesses use reads ACP_FAIL_MODE too (or a ~/.acp/failmode file). So does the Claude Code plugin from 0.30.1. Without the setting it fails open with an UNGOVERNED banner in interactive sessions and fails closed for subagent, background and API sessions.
A policy deny always blocks, whatever the fail mode. A machine with no credentials does nothing either way.
Related links
- opencode permissions reference: every key in the
permissionblock, defaults, config layers, auto-approve, worked examples - /controls/opencode: the rule language, the native prompt and the plugin surface
- /integrations/opencode: install guide, local metering and troubleshooting
- Claude Code hooks reference: the shell-hook shape, for comparison
- Codex hooks reference: a narrower hook surface that is still changing
- DeepSeek Harness (dsh) hooks reference: the other in-process plugin model
- OpenCode cost tracking: the local SQLite path and the proxy path for priced spend
Frequently asked questions
What's the primary hook the ACP plugin uses in opencode?
permission.ask. It fires when a tool call’s permission resolves to “ask” in opencode.json. The plugin can answer allow (skips the native prompt), deny (blocks the call), or leave it alone so opencode’s own once/always/reject prompt appears.
What happens if I don't add the permission block to opencode.json?
You get a deny-only backstop. permission.ask only fires for tools set to “ask”. Without the block, an ACP allow has no prompt to skip and an ACP ask has no prompt to reach. You still get the deny check in tool.execute.before and the output audit.
Does the plugin work without a workspace credential?
Not for policy. With no ACP_BEARER_TOKEN and no ~/.acp/credentials, the published plugin (acp-opencode 0.2.1) does nothing and opencode behaves as if it weren’t installed. The installer’s --local flag skips opencode and says so. Local metering does run with no credentials: every model call’s tokens and cost go to ~/.acp/opencode-local.db, and npx acp-opencode report reads it.
What happens to an ask verdict at tool.execute.before?
It becomes a deny. That hook can’t open a prompt. Opencode only shows approval prompts through permission.ask, and only for tools set to ask.
Running opencode? One command adds a plugin. Each tool call it sees is recorded, and a force-push, destructive SQL or curl | sh is blocked until you approve it on the console or from the email.
curl -fsSL https://agenticcontrolplane.com/install.sh | bash
irm https://agenticcontrolplane.com/install.ps1 | iex
What the installer writes · opencode guide · free up to 5 agents