anomalyco / anomalyco/opencode

Plugin API: ctx.tool.transform tools.add crashes with TypeError '_.name.replace' on undefined (beta-17498)

Open
#43,753 0 comments 0 reactions 1 assignee View on GitHub

@neriousy is already working on this.

Since Aug 21, 2026.

2.0
Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Version

opencode2 v0.0.0-beta-17498 (npm @opencode-ai/cli@next, Linux x64)

Description

Plugin-registered tools via ctx.tool.transform((tools) => tools.add(...)) fail to load with an internal Effect error. The plugin id appears in /api/plugin from a bare-load generation, but every generation that calls tools.add dies during activation.

Repro

Minimal plugin in ~/.config/opencode/plugins/broken.js:

export default {
  id: "broken",
  setup: async (ctx) => {
    await ctx.tool.transform((tools) => {
      tools.add("skills.browse", {
        description: "test",
        input: { type: "object", properties: {}, additionalProperties: false },
        execute: async () => ({ content: "ok" }),
      })
    })
    return async () => {}
  },
}

Server log:

level=WARN message="failed to load plugin" plugin.id=broken cause="Cause([Die(TypeError: undefined is not an object (evaluating '_.name.replace'))])"
Observations
  • A plugin whose setup does nothing except console.log loads fine, so the crash is specifically in the tool registration path.
  • The documented third-argument options form (tools.add("browse", def, { namespace: "skills" })) crashes the same way.
  • Adding an output JSON Schema makes no difference; the crash also happens without it.
  • Same failure on two different plugin files and across watcher-triggered reloads, so it is not a race in my file editing.
  • Docs at /v2/docs/build/plugins describe both call shapes; at least one of them appears broken on this beta.
Expected

tools.add(name, definition) registers a tool that is exposed to the model (and via CodeMode), or returns a validation error naming the offending field.

Environment

Linux x64, Bun runtime bundled with the CLI, plugins auto-discovered from ~/.config/opencode/plugins/.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.