diff --git a/packages/react/src/runtimes/edge/streams/toolResultStream.ts b/packages/react/src/runtimes/edge/streams/toolResultStream.ts index 0644e343a..8d3757044 100644 --- a/packages/react/src/runtimes/edge/streams/toolResultStream.ts +++ b/packages/react/src/runtimes/edge/streams/toolResultStream.ts @@ -27,7 +27,7 @@ export function toolResultStream(tools: Record | undefined) { case "tool-call": { const { toolCallId, toolCallType, toolName, args: argsText } = chunk; const tool = tools?.[toolName]; - if (!tool) return; + if (!tool || !tool.execute) return; const args = sjson.parse(argsText); if (tool.parameters instanceof z.ZodType) { @@ -43,7 +43,7 @@ export function toolResultStream(tools: Record | undefined) { toolCallId, (async () => { try { - const result = await tool.execute(args); + const result = await tool.execute!(args); controller.enqueue({ type: "tool-result", diff --git a/packages/react/src/types/ModelConfigTypes.ts b/packages/react/src/types/ModelConfigTypes.ts index 7c5666176..047a47834 100644 --- a/packages/react/src/types/ModelConfigTypes.ts +++ b/packages/react/src/types/ModelConfigTypes.ts @@ -8,7 +8,7 @@ type ToolExecuteFunction = ( export type Tool = { description?: string | undefined; parameters: z.ZodSchema | JSONSchema7; - execute: ToolExecuteFunction; + execute?: ToolExecuteFunction; }; export type ModelConfig = { diff --git a/packages/react/src/types/index.ts b/packages/react/src/types/index.ts index 338c3ac58..850eff0ad 100644 --- a/packages/react/src/types/index.ts +++ b/packages/react/src/types/index.ts @@ -34,6 +34,10 @@ export type { ToolCallContentPartComponent, } from "./ContentPartComponentTypes"; -export type { ModelConfig, ModelConfigProvider } from "./ModelConfigTypes"; +export type { + ModelConfig, + ModelConfigProvider, + Tool, +} from "./ModelConfigTypes"; export type { Unsubscribe } from "./Unsubscribe";