fix: handle tool calls in streaming mode - fall back to non-streaming
Model says "let me research" then calls web_search tool. Streaming path ignored tool_calls entirely (no-op comment). Now: detect tool_calls delta, cancel stream, fall back to non-streaming which properly executes tools and returns results.
This commit is contained in:
@@ -379,10 +379,11 @@ export async function initBot(config, api, tools, skills, agents) {
|
|||||||
fullResponse += content;
|
fullResponse += content;
|
||||||
onDelta(content);
|
onDelta(content);
|
||||||
}
|
}
|
||||||
// Check for tool calls in streaming
|
// Tool calls in streaming - abort stream, fall back to non-streaming (handles tools)
|
||||||
if (delta.tool_calls) {
|
if (delta.tool_calls) {
|
||||||
// Tool calls in streaming mode — accumulate and handle after stream
|
logger.info("Tool call in stream, falling back to non-streaming");
|
||||||
// For now, fall through to non-streaming tool handling
|
reader.cancel().catch(() => {});
|
||||||
|
return await chatWithAI(body.messages, { maxTokens: body.max_tokens });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
Reference in New Issue
Block a user