Skip to content
Agentic Control Plane

OpenCode 2.0 Plugin API Changes: What Breaks and How to Check Your Plugin Still Runs

David Crowe David Crowe · · Updated · 8 min read
opencode hooks permissions plugins reference
Share X HN LinkedIn

Summary, as of 15 October 2026. OpenCode 2.0 (tags v2.0.22+, not yet on latest) replaces the plugin contract. A 1.x plugin does not load. Model calls through a configured provider keep working, so the session looks the same. To check: run a call your policy denies, then look for its audit row.

1.x hooks reference →  ·  1.x permissions reference →  ·  install guide →

We run a daily canary. It installs the current release of every harness we support, installs our plugin with the live installer, makes one call through it, and checks that an audit row landed. On 13 October it installed opencode v2.0.27 and reported this:

ACP · session governed: 3 model calls · 2 tool calls · 2.6¢
FAIL no audit row for opencode since 2026-10-13T04:52:21.000Z within 120s

Three model calls were priced. Two tool calls ran. No audit rows. The session summary said governed, and the tool boundary recorded nothing. Ten hours later the canary installed 1.19.0 and went green, because upstream had pointed its installer back at a v1 branch.

That gap is what this post is about. A harness release can turn off a permissions plugin with no visible error, and only a scheduled call with a check on the other end caught it.

What is in the 2.0 train

Everything below comes from tag v2.0.29 on sst/opencode (tagged 14 October), compared with v1.19.0. There are no release notes. The release body is the string release: v2.0.29.

The repo is restructured. packages/opencode is gone. The runtime is now @opencode/core, @opencode/cli and @opencode/server. There are thirty-six packages where there used to be a handful.

The plugin package is renamed and rewritten. @opencode-ai/plugin becomes @opencode/plugin, published on npm at 2.0.29 next to @opencode/schema, @opencode/client and @opencode/sdk. In 1.x a plugin was a function that returned an object of named hooks. In 2.0 it is a definition with a setup function that registers hooks one at a time:

import { Plugin } from "@opencode/plugin"

export default Plugin.define({
  id: "example",
  setup: async (ctx) => {
    await ctx.permission.hook("evaluate", (e) => {
      // e.effect is "allow" | "deny" | "ask", already computed from the user's rules
    })
    await ctx.tool.hook("execute.before", (e) => { /* e.tool, e.id, e.input */ })
    await ctx.tool.hook("execute.after", (e) => { /* e.status, e.result | e.error */ })
    await ctx.session.hook("http.request", (e) => { e.request.headers.set("X-Example", "1") })
    return () => { /* cleanup on unload */ }
  },
})

The 1.x hook names are gone. Searching packages/core/src at v2.0.29 for permission.ask, tool.execute.before, tool.execute.after, chat.headers, event and shell.env finds nothing. No alias, no rename shim.

The loader rejects a 1.x export. packages/core/src/plugin/module.ts checks the default export and fails with:

Plugin must export a default definition with an id and an effect or setup function.

Config migrates. plugin: [...] is read as legacy and folded into the new plugins list. The v1 permission and provider blocks each have a migration under packages/core/src/v1/config/. Your opencode.json keeps working, which is why the failure is quiet.

Old hook to new hook

1.x (@opencode-ai/plugin) 2.0 (@opencode/plugin)
export default async (input, options) => ({ ...hooks }) export default Plugin.define({ id, setup(ctx) })
"permission.ask"(input, output) sets output.status ctx.permission.hook("evaluate", e => { e.effect = … })
"tool.execute.before"(input, output), throw to block ctx.tool.hook("execute.before", e => …), throw to block
"tool.execute.after"(input, output) ctx.tool.hook("execute.after", e => …) with status: "completed" \| "error"
"chat.headers"(input, output) ctx.session.hook("http.request", e => e.request.headers.set(…))
"event" ctx.event.subscribe(…)
"shell.env" ctx.shell.hook("create.before", e => { e.env … })
second argument options ctx.options

Two details if you port a plugin.

First, the permission event now carries effect already resolved from the user’s rules. A plugin can see that the user already denied a call and leave it alone. In 1.x the hook fired only for ask, so the plugin couldn’t tell.

Second, the permission request is addressed by action and resources, not by tool name and arguments. edit and write both evaluate as action edit with the file path as the resource. webfetch evaluates with the URL. The tool’s full input arrives later at execute.before, under the same call id that the permission event carries in source.id. If your plugin needs the arguments to decide, cache them at execute.before and read them back in evaluate.

Why nothing tells you

A 2.0 session with a 1.x plugin still does three things that look like it’s working. The provider block sends model calls through whatever proxy you configured, so they get priced and show up in a cost summary. The permission block still prompts for ask rules, so you still see OpenCode’s own approvals. And the plugin’s session-start line never prints, which nobody notices.

What stops: the check against workspace policy before each call, the pre-approval that skips the prompt when policy says allow, and the audit row per tool call. Those three are the plugin. The cost summary comes from the proxy.

So “I see cost” and “I see prompts” prove nothing. Do this instead:

  1. Run one tool call your workspace policy denies. If it executes, no plugin is deciding.
  2. Open the audit log for that session. If the model calls are there and the tool calls aren’t, you are looking at what our canary saw.

What we changed in acp-opencode

OpenCode 2.0 looks for a plugin package at <package>/server before <package>. So one npm package can hold both: the root export stays the 1.x hooks object, and a ./server export holds the 2.0 definition. 1.x never asks for the subpath. 2.0 asks for it first.

The 2.0 entry maps the same behavior onto the new hooks:

  • evaluate posts the call to the workspace and sets effect to allow or deny. It leaves ask to OpenCode’s own prompt and never loosens a deny that came from upstream.
  • execute.before is a deny-only backstop for tools that never reach a permission rule.
  • execute.after writes the audit row.
  • http.request stamps the session id, so proxy-side spend lines up with hook-side audit rows.

Kill switch, credentials and fail posture are the same as 1.x. Not ported yet: the local SQLite metering (the 2.0 event bus has a different shape) and the TUI toasts.

Your existing config works on both:

{
  "$schema": "https://opencode.ai/config.json",
  "plugin": ["acp-opencode"],
  "permission": { "bash": "ask", "edit": "ask", "webfetch": "ask" }
}

Two caveats. The 2.0 entry is tested against the contract read from the tag and a fake context, not against a real 2.0 binary, because 2.0 releases ship source archives only and opencode-ai on npm has no 2.x. And the API is a nightly train with no notes. The hook names above are what v2.0.29 has, and a later tag can move them. The canary will tell us when it does.

Every harness will do this once

Plugin APIs are the youngest part of each harness, and the harness authors owe you no stability there. When one changes, you don’t get a crash. You get a session that looks like yesterday’s with the checks missing.

Two things help. First, a scheduled call through the real installed harness, with a check on the audit side, so you find the gap the same day. Second, a policy that lives with your workspace and not in the harness, so a change to a harness’s plugin surface changes how you attach, not what you enforce. The hook still runs on your machine, so the canary stays necessary.

Share X HN LinkedIn
Get the next data drop
What agents actually cost, new tool-surface captures, and the occasional incident post-mortem — sent when we publish something worth your inbox, not on a schedule. Unsubscribe anytime.
Share: Twitter LinkedIn
Related posts

← back to blog