Fail runs whose first turn carries no text and no tool calls
A reasoning-heavy model can burn the whole max_tokens budget on thinking blocks; the parsed turn then has neither text nor tool calls and the loop treated it as a successful completion, marking a run done when nothing happened. Such a first turn now fails the run so the failure is visible and the heartbeat retries; later empty-text turns after real tool work still complete normally.
This commit is contained in:
1 parent
d6d6656428
commit
b4e17cbd35
2 files changed
+28
No files matched your search
@@ -48,6 +48,12 @@ export async function runAgentLoop(deps: AgentRunLoopDeps, input: AgentRunLoopIn
|
||||
lastRequestId = turn.requestId;
|
||||
|
||||
if (turn.toolCalls.length === 0) {
|
||||
if (toolCallCount === 0 && !turn.text.trim()) {
|
||||
// A first turn with neither text nor tool calls means the provider
|
||||
// produced nothing actionable (e.g. output truncated mid-reasoning);
|
||||
// completing the run would silently mark a no-op as done.
|
||||
throw new Error("Provider returned an empty turn: no text and no tool calls.");
|
||||
}
|
||||
return { finalText: turn.text, iterations: iteration, toolCallCount, lastRequestId };
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user