Description
When a project has a .opencode/tool/*.{js,ts} file that fails to load (for example, it imports a package that couldn't be installed), the failure dies the entire tool registry — and with it, every session run in that project. A single bad tool file makes the project unusable.
The tool registry in packages/opencode/src/tool/registry.ts globs {tool,tools}/*.{js,ts} and dynamically import()s each file with no error handling around the import. If the file throws (e.g. ResolveMessage: Cannot find package ...), the defect propagates and kills the registry's state effect, so the whole run fails. Any valid tool files in the same project never get a chance to load.
Steps to reproduce
- Create a project with a broken custom tool:
// .opencode/tool/broken.ts
import { tool } from "@opencode-ai/plugin"
import { something } from "@opencode-ai/definitely-not-a-real-package"
export default tool({ description: "broken", args: { x: tool.schema.string() }, async execute() { return "" } })
- Open that project in the web UI and send any prompt.
- Observed: the whole run dies with the
ResolveMessage stack instead of answering.
Expected
A failing tool file should be skipped with a warning, and the rest of the tool registry (including valid sibling tool files) should still load so the session can proceed.
Notes
Description
When a project has a
.opencode/tool/*.{js,ts}file that fails to load (for example, it imports a package that couldn't be installed), the failure dies the entire tool registry — and with it, every session run in that project. A single bad tool file makes the project unusable.The tool registry in
packages/opencode/src/tool/registry.tsglobs{tool,tools}/*.{js,ts}and dynamicallyimport()s each file with no error handling around the import. If the file throws (e.g.ResolveMessage: Cannot find package ...), the defect propagates and kills the registry's state effect, so the whole run fails. Any valid tool files in the same project never get a chance to load.Steps to reproduce
ResolveMessagestack instead of answering.Expected
A failing tool file should be skipped with a warning, and the rest of the tool registry (including valid sibling tool files) should still load so the session can proceed.
Notes
opencode serveAPI driven from a browser session); I did not test or investigate the TUI.