diff --git a/src/app/api/chat/route.ts b/src/app/api/chat/route.ts index 7e1e01253..7f477d22e 100644 --- a/src/app/api/chat/route.ts +++ b/src/app/api/chat/route.ts @@ -83,20 +83,35 @@ export async function POST(request: NextRequest) { const toolsToPass = agent.tools || {} console.log(`[chat] Tools available for agent ${agentId}:`, Object.keys(toolsToPass)) + // TEMPORARY: Disable tools for debugging + // Remove once tool calling issue is resolved + const toolsForStreaming = Object.keys(toolsToPass).length > 0 ? undefined : toolsToPass + if (Object.keys(toolsToPass).length > 0) { + console.log(`[chat] WARNING: Tools are defined but being disabled temporarily due to CPU limit issue`) + } + // Stream response from agent + console.log(`[chat] Starting streamText for agent ${agentId}`) + const startTime = Date.now() + const result = streamText({ model, system: agent.systemPrompt, - tools: toolsToPass, + tools: toolsForStreaming, // Temporarily disabled messages, temperature: agent.temperature, // Note: maxTokens is not used in streamText - it uses maxRetries, retry logic, etc onFinish: (event) => { - console.log(`[chat] Response completed for agent ${agentId}`) + const duration = Date.now() - startTime + console.log(`[chat] Response completed for agent ${agentId}, duration: ${duration}ms`) + if (event.usage) { + console.log(`[chat] Token usage - input: ${event.usage.inputTokens}, output: ${event.usage.outputTokens}`) + } }, }) // Return as text stream response (Server-Sent Events format) + console.log(`[chat] Converting to text stream for agent ${agentId}`) return result.toTextStreamResponse() } catch (error) { console.error('[chat] Error:', error)