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
- config:
"plugins": ["/abs/plugin"] (a directory containing index.js)
- boot a location:
GET /api/agent?directory=/tmp/proj
mv /abs/plugin /abs/plugin.old
- 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
- start
opencode serve --port 49998 with a config whose plugins[] lists a path that cannot be resolved
GET /api/agent?directory=/tmp/proj (boots location services)
POST /api/location/reload → 503 {"_tag":"ServiceUnavailableError","message":"TypeError: o is not a function. (In 'o()', ...)"}
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.