This commit is contained in:
Zacharias-Brohn
2026-01-15 00:19:36 +01:00
parent 5fe57ac3d6
commit f920c37cf7
+9 -1
View File
@@ -235,10 +235,18 @@ export async function POST(request: NextRequest) {
// Process tool calls // Process tool calls
controller.enqueue(encoder.encode('\n\n')); 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({ workingMessages.push({
role: 'assistant', role: 'assistant',
content: fullContent, content: fullContent,
tool_calls: toolCalls.map((tc) => ({
function: {
name: tc.name,
arguments: tc.arguments,
},
})),
}); });
// Execute each tool and collect results // Execute each tool and collect results