Skip to content

Commit 0ea9a56

Browse files
committed
Fix empty-response recovery attempt accounting
1 parent 327f36a commit 0ea9a56

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

packages/agent/src/attach.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,15 @@ export function installCuaBehaviors(
161161
hasPendingQueue = false;
162162
return undefined;
163163
}));
164-
offs.push(harness.subscribe((event: any, signal?: AbortSignal) => {
164+
offs.push(harness.subscribe(async (event: any, signal?: AbortSignal) => {
165165
if (event.type === "message_end" && event.message.role === "assistant") turnFailed = false;
166166
else if (event.type === "tool_execution_end" && event.isError) turnFailed = true;
167167
else if (event.type === "queue_update") hasPendingQueue = event.steer.length > 0 || event.followUp.length > 0;
168168
if (!recovery || recovery.maxAttempts <= 0) return;
169169
if (event.type !== "turn_end" || !isEmptyAssistantResponse(event.message)) return;
170170
if (signal?.aborted || recoveryAttempts >= recovery.maxAttempts || hasPendingQueue) return;
171+
await harness.followUp(recovery.followUp);
171172
recoveryAttempts += 1;
172-
return harness.followUp(recovery.followUp);
173173
}));
174174

175175
return () => {

0 commit comments

Comments
 (0)