fix(cli/run): move error check before idle/tool gates in pollForCompletion
This commit is contained in:
@@ -25,16 +25,7 @@ export async function pollForCompletion(
|
||||
while (!abortController.signal.aborted) {
|
||||
await new Promise((resolve) => setTimeout(resolve, pollIntervalMs))
|
||||
|
||||
if (!eventState.mainSessionIdle) {
|
||||
consecutiveCompleteChecks = 0
|
||||
continue
|
||||
}
|
||||
|
||||
if (eventState.currentTool !== null) {
|
||||
consecutiveCompleteChecks = 0
|
||||
continue
|
||||
}
|
||||
|
||||
// ERROR CHECK FIRST — errors must not be masked by other gates
|
||||
if (eventState.mainSessionError) {
|
||||
console.error(
|
||||
pc.red(`\n\nSession ended with error: ${eventState.lastError}`)
|
||||
@@ -45,6 +36,16 @@ export async function pollForCompletion(
|
||||
return 1
|
||||
}
|
||||
|
||||
if (!eventState.mainSessionIdle) {
|
||||
consecutiveCompleteChecks = 0
|
||||
continue
|
||||
}
|
||||
|
||||
if (eventState.currentTool !== null) {
|
||||
consecutiveCompleteChecks = 0
|
||||
continue
|
||||
}
|
||||
|
||||
if (!eventState.hasReceivedMeaningfulWork) {
|
||||
consecutiveCompleteChecks = 0
|
||||
continue
|
||||
|
||||
Reference in New Issue
Block a user