Repository navigation
Description
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]; npmdist-tags.latest=2.1.4at 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 2opencode 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 containingindex.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 49998with a config whoseplugins[]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.
Activity
opencode-agent commentedon Oct 26, 2026
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:
pe is not a function … instance of Object) after plugin files changed or were deleted leaves only builtin agents and commands until restart.re is not a function) in every location, which wipe the provider registry and sometimes causeSession.AgentNotFoundError.opencode reloadagainst the background service crashes with TypeError in ServerProcess.start / Worktree.refresh (2.1.2, Windows); --standalone reload works #57719:opencode reloadagainst the background service crashes with the same kind of TypeError. Open PR fix(plugin): only call function return values when tearing down a plugin #57775 proposes a fix that only calls a plugin's cleanup if it's actually a function.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.
rekram1-node commentedon Oct 28, 2026
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.