This commit is contained in:
seb
2026-10-01 10:18:57 +02:00
parent 5dee37cb2b
commit a58991b9f8
3 changed files with 114 additions and 3 deletions

View File

@@ -200,16 +200,23 @@ class LLMOrbiter {
const toolCalls = completion.tool_calls;
const content = completion.content;
const hasToolCalls = Array.isArray(toolCalls) && toolCalls.length > 0;
const hasContent = typeof content === 'string' && content.trim().length > 0;
// When there is no response (neither tool calls nor content), the loop shall continue.
if (!hasToolCalls && !hasContent) {
continue;
}
// Push assistant message
messages.push({
role: 'assistant',
content: content || null,
...(toolCalls?.length ? { tool_calls: toolCalls } : {}),
...(hasToolCalls ? { tool_calls: toolCalls } : {}),
});
// No tool calls → done
if (!toolCalls?.length) {
if (!hasToolCalls) {
finalContent = content;
break;
}