fix(tools): isolate tool schemas and waterfall failures

This commit is contained in:
Tianyi Cui
2026-06-17 21:26:12 +08:00
parent 922e2f913e
commit 87df09e3c3
4 changed files with 66 additions and 3 deletions
+12 -1
View File
@@ -173,7 +173,10 @@ export class ToolRegistry extends Service {
schemas(): ToolSchema[] {
// Rest-destructure to drop `execute`; the unused binding is the idiom.
// eslint-disable-next-line @typescript-eslint/unbound-method, @typescript-eslint/no-unused-vars
return [...this.store.values()].map(({ execute, ...schema }) => schema)
return [...this.store.values()].map(({ execute, ...schema }) => ({
...schema,
parameters: structuredClone(schema.parameters),
}))
}
/**
@@ -201,6 +204,14 @@ export class ToolRegistry extends Service {
...info ? { error: info } : {},
}
}
}).catch((error: unknown): ToolExecutionResult => {
const info = errorInfo(error)
return {
callId: exec.callId,
content: [{ type: 'text', text: `Error: ${errorMessage(error)}` }],
isError: true,
...info ? { error: info } : {},
}
})
}
}