From f920c37cf7b5f77a778fcace450579967475fc4c Mon Sep 17 00:00:00 2001 From: Zacharias-Brohn Date: Thu, 15 Jan 2026 00:19:36 +0100 Subject: [PATCH] changes --- app/api/chat/route.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/api/chat/route.ts b/app/api/chat/route.ts index a2d9599..9861f36 100644 --- a/app/api/chat/route.ts +++ b/app/api/chat/route.ts @@ -235,10 +235,18 @@ export async function POST(request: NextRequest) { // Process tool calls controller.enqueue(encoder.encode('\n\n')); - // Add the assistant's response to messages + // Add the assistant's response to messages WITH tool_calls + // This is critical - the model needs to see what tools IT requested + // so it understands the tool results that follow workingMessages.push({ role: 'assistant', content: fullContent, + tool_calls: toolCalls.map((tc) => ({ + function: { + name: tc.name, + arguments: tc.arguments, + }, + })), }); // Execute each tool and collect results