fix(ralph-loop): add inFlight guard and improve completion detection to prevent infinite loops

Closes #2084
This commit is contained in:
YeonGyu-Kim
2026-02-26 20:58:55 +09:00
parent 38466ec676
commit 5892d0fbb1
4 changed files with 211 additions and 116 deletions
@@ -79,8 +79,8 @@ export async function detectCompletionInSessionMessages(
if (assistantMessages.length === 0) return false
const pattern = buildPromisePattern(options.promise)
const recentAssistants = assistantMessages.slice(-3)
for (const assistant of recentAssistants) {
for (let index = assistantMessages.length - 1; index >= 0; index -= 1) {
const assistant = assistantMessages[index]
if (!assistant.parts) continue
let responseText = ""