anomalyco / anomalyco/opencode

Tool files that fail to load crash the whole session/registry instead of being skipped

Open
#42,258 2 comments 0 reactions 1 assignee View on GitHub

@jlongster is already working on this.

Since Aug 13, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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
  1. 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 "" } })
    
  2. Open that project in the web UI and send any prompt.
  3. 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
  • I hit this using headless opencode via the web browser (the opencode serve API driven from a browser session); I did not test or investigate the TUI.
  • Fix: skip the broken file and log a warning (PR #42252); surfacing the warning as an inline UI card is covered by the companion issue #42251 / PR #42253.
  • The trigger here (an auto-installed tool dependency failing to resolve) is separate from the module-resolution mechanism itself; a missing/uninstallable package in any tool file reproduces it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.