Skip to content

Commit 970531f

Browse files
engineerCopilot
andcommitted
fix(tool): skip malformed tool entries during init
Co-authored-by: Copilot <[email protected]>
1 parent 3185fd2 commit 970531f

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

‎packages/opencode/src/tool/registry.ts‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ export namespace ToolRegistry {
150150
const result = await Promise.all(
151151
tools
152152
.filter((t) => {
153+
if (typeof (t as any)?.init !== "function") {
154+
log.warn("skipping invalid tool", { id: (t as any)?.id ?? "unknown" })
155+
return false
156+
}
157+
153158
// Enable websearch/codesearch for zen users OR via enable flag
154159
if (t.id === "codesearch" || t.id === "websearch") {
155160
return model.providerID === ProviderID.opencode || Flag.OPENCODE_ENABLE_EXA
@@ -164,15 +169,16 @@ export namespace ToolRegistry {
164169
return true
165170
})
166171
.map(async (t) => {
167-
using _ = log.time(t.id)
168-
const tool = await t.init({ agent })
172+
const item = t as Tool.Info
173+
using _ = log.time(item.id)
174+
const tool = await item.init({ agent })
169175
const output = {
170176
description: tool.description,
171177
parameters: tool.parameters,
172178
}
173-
await Plugin.trigger("tool.definition", { toolID: t.id }, output)
179+
await Plugin.trigger("tool.definition", { toolID: item.id }, output)
174180
return {
175-
id: t.id,
181+
id: item.id,
176182
...tool,
177183
description: output.description,
178184
parameters: output.parameters,

0 commit comments

Comments
 (0)