u
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user