Skip to content

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

Closed as not planned

Description

@MisterWanted

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/.

Activity

  1. added 4 commits that reference this issue on Aug 21, 2026
    8e319db
    ff0c5f8
  2. github-actions commented on Oct 21, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions