Skip to content

fix(core): isolate invalid plugin tools during materialize#37944

Open
BrightonXX wants to merge 2 commits into
anomalyco:v2from
BrightonXX:tool-materialize-isolate-rebased
Open

fix(core): isolate invalid plugin tools during materialize#37944
BrightonXX wants to merge 2 commits into
anomalyco:v2from
BrightonXX:tool-materialize-isolate-rebased

Conversation

@BrightonXX

Copy link
Copy Markdown

Issue for this PR

Closes #35963

Type of change

  • Bug fix

What does this PR do?

A structurally invalid plugin tool (missing description, undecodable schema, opaque object from a different module copy) throws inside materialize() and breaks every subsequent model step in the Location because no definition list can be produced.

materialize() now wraps each definition() call in try/catch. On failure: log a warning with the tool name and error, drop the registration from the direct map so later settle() calls do not surface it as usable, and continue building the rest of the catalog. The dropped tool settles as Unknown tool: <name> instead of re-throwing.

How did you verify your code works?

cd packages/core && bun test test/session-runner-tool-registry.test.ts   # 18 pass, 0 fail
bun turbo typecheck --filter=@opencode-ai/core...                         # 17/17 green

Reverse verification: reverting packages/core/src/tool/registry.ts makes the new test fail with TypeError: Cannot read properties of undefined (reading '~context') from inside materialize().

Screenshots / recordings

Not applicable — this is a core logic change, not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant