Skip to content

Hot plugin reload destroys the shared agent/skill registry for all locations (TypeError: o is not a function) #59443

Closed as duplicate

Description

@fakekun420-ui

Summary

On 2.1.4, a hot plugin reload caused by a filesystem change under a path declared in plugins[] throws
TypeError: o is not a function and does not fail only that plugin: it tears down the shared registry of
agents/skills/tools for every booted location. In-flight turns then die with AgentNotFoundError and
permission.rejected.

Environment

  • opencode 2.1.4 (@opencode/[email protected]; npm dist-tags.latest = 2.1.4 at the time of writing)
  • Linux 4.19 aarch64 (Ubuntu 24.04 chroot on Android), node v20.20.2, bun 1.4.4
  • one service on 127.0.0.1:49374 (opencode serve --service), 6 booted locations
  • config declares two external plugin directories ("plugins": ["/abs/pluginA", "/abs/pluginB"])

Symptoms

ERROR failed to reload plugins  cause="Cause([Die(TypeError: o is not a function. (In 'o()', 'o' is an instance of Object))])"
ERROR Failed to drain Session   cause="Session.AgentNotFoundError: Agent not found: \"orquestador\""

Tool calls that were in flight are rejected:

{"error":{"type":"permission.rejected","message":"Permission denied: shell"}}

Registry before/after the event:

  • GET /api/skill → 74, then 2
  • opencode debug agents → 14, then 7 (builtins only)
  • the same for every location, and it does not recover on its own

Repro A — a declared plugin directory disappears while the server runs

  1. config: "plugins": ["/abs/plugin"] (a directory containing index.js)
  2. boot a location: GET /api/agent?directory=/tmp/proj
  3. mv /abs/plugin /abs/plugin.old
  4. in the same second the log shows:
WARN  failed to load plugin  target=/abs/plugin  cause="... ENOENT: no such file or directory ..."
ERROR failed to reload plugins  TypeError: o is not a function
ERROR Failed to drain Session   Agent not found: "<agent>"

Writing a file inside that directory produces the same result: the reload path is entered either way.

Repro B — reload with a booted location

  1. start opencode serve --port 49998 with a config whose plugins[] lists a path that cannot be resolved
  2. GET /api/agent?directory=/tmp/proj (boots location services)
  3. POST /api/location/reload → 503 {"_tag":"ServiceUnavailableError","message":"TypeError: o is not a function. (In 'o()', ...)"}
  4. GET /api/skill?directory=/tmp/proj → {"data": []}

Caveat, to be precise: on a server where the same plugin set is already loaded, POST /api/location/reload
returns 204 and logs location services reloaded count=6. So it is not reload itself, it is the reload that
happens when the plugin set/instances change (or when a declared plugin fails to load) that takes the registry
down.

Expected

  • A plugin that fails to load should be skipped/reported, leaving the rest of the registry intact.
  • A failed reload should not leave every location without agents and skills.

Actual

  • The shared registry is dropped for all locations and every in-flight session dies mid-turn.

Impact

Any agent session on the machine dies when a declared plugin file is touched, including routine work by an
unrelated agent. Restarting the service is the only reliable recovery (an explicit POST /api/location/reload
sometimes restores it, sometimes returns 503).

Happy to test a specific build or provide full opencode.log excerpts.

Activity

  1. opencode-agent commented on Oct 26, 2026

    @opencode-agent
    Contributor

    Thanks for the detailed report and the two reproductions. I think this is a duplicate of #49982. That issue reports a failed plugin reload throwing TypeError: … is not a function. (In '…()', '…' is an instance of Object) on the background service. After it, custom agents and commands disappear in every location until the service is restarted. That's the same failure you're seeing, now confirmed on 2.1.4.

    Possible duplicates and closely related issues, ordered from most to least likely:

    Your reproductions (a declared plugin directory moved or modified while sessions are running) and the 2.1.4 confirmation would be useful additions on #49982.

    The bot will close this issue as a duplicate in 1 day unless you reply explaining how your problem is different.

  2. rekram1-node commented on Oct 28, 2026

    @rekram1-node
    Collaborator

    Closing as a duplicate of the issue linked above. If this turns out to be a different problem, comment here and we'll reopen it.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions