debug: add logging to diagnose streaming issue in AI SDK v6

This commit is contained in:
Ajax Davis 2025-11-30 19:50:41 +10:00
parent 2a05e68aa3
commit 266a6ef74c

View file

@ -221,15 +221,21 @@ export async function executeToolWithAgent(
tools: toolsConfig,
onFinish: () => {
agentSteps++;
console.log('[executeToolWithAgent] Stream finished, steps:', agentSteps);
},
});
console.log('[executeToolWithAgent] Starting text stream consumption');
// Stream and collect text
for await (const chunk of result.textStream) {
console.log('[executeToolWithAgent] Received chunk:', chunk);
fullOutput += chunk;
onChunk?.(chunk);
}
console.log('[executeToolWithAgent] Text stream complete, fullOutput length:', fullOutput.length);
// Calculate final token breakdown
const parameters = Array.isArray(tool.parameters)
? (tool.parameters as unknown as TPMJSParameter[])