Skip to content

plugins: mid-turn watcher reload invalidates tool registry (Unknown tool) #40825

Closed

Description

@akramdotsh

Summary

Plugin tools registered with codemode: true are listed in the session catalog, but calls fail with "Unknown tool" whenever a watcher-triggered plugin reload lands while that turn is in flight. The reload releases the old plugin generation's registrations, so the tool the model is already calling no longer resolves.

Environment

  • opencode version: 0.0.0-next-16902
  • OS: Darwin 25.6.0 (arm64)
  • Terminal: ghostty (xterm-256color)
  • Shell: /bin/zsh
  • Install/channel: next (npm)
  • Active plugins: ~/.config/opencode/plugins/goal.ts, loop.ts, moshi-hooks.ts

Reproduction

  1. Add a plugin registering a tool via ctx.tool.transform with options: { codemode: true }.
  2. Start a turn that will call the tool.
  3. While the turn is running, edit/touch any file under ~/.config/opencode/plugins/ (the config watcher reloads all plugins).
  4. Model calls the tool → runtime rejects with "Unknown tool", even though the tool is in the catalog shown to the model.

Expected Behavior

In-flight tool calls keep working; the session context reflects the post-reload tool registry (or the reload waits for the turn to finish).

Actual Behavior

Intermittent "Unknown tool" failures on exactly the plugin-provided tools, matching the timing of watcher reloads. Recovered on the next turn. Saw this twice in one session, both times tied to plugin file mtime changes mid-turn.

Additional Context

Workaround: restart the service after any plugin file edit. Nothing in the plugin API lets a plugin pin its registration across a reload, so this needs a server-side fix: e.g. reload should not release tool registrations mid-turn, or the session context/tool resolution should rebuild after reload.

Activity

  1. github-actions commented on Aug 6, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    • fix(core): isolate invalid plugin tools during reload #35963: Closely related — covers plugin reload invalidating tool registrations, breaking session materialization, and the lack of atomic/isolated per-plugin reload semantics. The mid-turn race described here (watcher reload while a tool call is in flight) is a specific manifestation of the broader reload isolation gap tracked there.
  2. akramdotsh commented on Aug 6, 2026

    @akramdotsh
    Author

    Closing as duplicate of #35963, which tracks the broader plugin reload isolation gap. The repro steps here remain a concrete manifestation of it.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions