You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
bug: tool.registry test fails on CI — custom tool import crashes registry when dependencies are missing #12269
The test tool.registry > loads tools with external dependencies without crashing introduced in #12227 (556adad67) fails deterministically on CI:
error: Cannot find package 'cowsay' from '/tmp/opencode-test-xxx/.opencode/tools/cowsay.ts'
(fail) tool.registry > loads tools with external dependencies without crashing [269.71ms]
This blocks all PRs targeting dev — the test (linux) check fails with 881 pass / 1 fail.
Root cause
Two issues:
No error handling in ToolRegistry.state() — await import(match) on line 44 of registry.ts throws when a custom tool has unresolvable dependencies, crashing the entire registry initialization instead of gracefully skipping the broken tool.
Test expects successful load without installing deps — the test creates a package.json with cowsay dependency but the dependency is never installed in the temp directory. Config.waitForDependencies() doesn't trigger the install in the test context. The test then asserts expect(ids).toContain("cowsay") which fails because the import throws.
Impact
Every PR targeting dev fails the test (linux) CI check. This started after #12227 was merged.
Suggested fix
Wrap the import(match) in registry.ts with try/catch — log a warning and skip tools that fail to import
Update the test expectation to not.toContain("cowsay") since the test name says "without crashing" (testing resilience, not successful loading)
Activity
wlioi commentedon Feb 5, 2026
Related Issue: Zod TypeError in Custom Tools (#12336)
I reported a separate but related issue (#12336) about Zod schema validation failures when loading custom tools from the
.opencodedirectory.Summary of #12336
TypeError: undefined is not an object (evaluating 'schema._zod.def')src/session/prompt.ts:704:62(inresolveTools)toJSONSchemafunction lacks defensive checks when processing nested basic types likeZodString/ZodNumber@opencode-ai/plugintool()function with Zod schema argsConnection to this issue
Both issues involve custom tool loading failures:
Suggestion
Consider adding comprehensive error handling for custom tool loading that covers:
The issue occurs when OpenCode internally calls
z.toJSONSchema(item.parameters)during tool resolution.