fix: handle custom tool import failures gracefully in registry#12270
Open
mguttmann wants to merge 1 commit intoanomalyco:devfrom
Open
fix: handle custom tool import failures gracefully in registry#12270mguttmann wants to merge 1 commit intoanomalyco:devfrom
mguttmann wants to merge 1 commit intoanomalyco:devfrom
Conversation
The tool registry now catches and logs errors when a custom tool fails to import (e.g. due to unresolvable dependencies) instead of crashing the entire registry initialization. Also fixes the 'loads tools with external dependencies without crashing' test which was failing on CI because cowsay was never installed in the temp directory.
Contributor
|
The following comment was made by an LLM, it may be inaccurate: No duplicate PRs found |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #12269 — the tool registry now catches and logs errors when a custom tool fails to import (e.g. due to unresolvable dependencies) instead of crashing the entire registry initialization.
Changes
packages/opencode/src/tool/registry.ts— wrapimport(match)in try/catch, log warning and skip tools that fail to loadpackages/opencode/test/tool/registry.test.ts— fix theloads tools with external dependencies without crashingtest to verify resilience (registry doesn't crash) rather than expecting the tool to be loaded when its dependencies can't be resolvedContext
Commit
556adad67(#12227) added a test that creates a custom tool importingcowsay, but the dependency is never installed in the test's temp directory. This causes a deterministic failure on CI that blocks all PRs targetingdev:The production code fix (try/catch) is also good defensive programming — if
bun installfails for any reason (network error, disk full, etc.), the registry should still work for all other tools rather than crashing entirely.