diff --git a/packages/shared-chat/src/utils/execute-tool.ts b/packages/shared-chat/src/utils/execute-tool.ts index c82791e..e7213e9 100644 --- a/packages/shared-chat/src/utils/execute-tool.ts +++ b/packages/shared-chat/src/utils/execute-tool.ts @@ -32,7 +32,7 @@ export const executeTool = async ({ abortSignal, messages, toolCall, tools }: Ex if (toolCall.function.arguments == null) throw new Error(`Missing toolCall.function.arguments: ${JSON.stringify(toolCall)}`) - const parsedArgs = JSON.parse(toolCall.function.arguments) as Record + const parsedArgs = JSON.parse(toolCall.function.arguments.trim() || '{}') as Record const result = wrapToolResult(await tool.execute(parsedArgs, { abortSignal, messages,