* fix(ralph-loop): skip user messages in transcript completion detection (#622) The transcript-based completion detection was searching the entire JSONL file for <promise>DONE</promise>, including user message entries. The RALPH_LOOP_TEMPLATE instructional text contains this literal pattern, which gets recorded as a user message, causing false positive completion detection on every iteration. This made the loop always terminate at iteration 1. Fix: Parse JSONL entries line-by-line and skip entries with type 'user' so only tool_result/assistant entries are checked for the completion promise. Also remove the hardcoded <promise>DONE</promise> from the template exit conditions as defense-in-depth. * chore: changes by sisyphus-dev-ai --------- Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
This commit is contained in:
@@ -100,7 +100,18 @@ export function createRalphLoopHook(
|
||||
|
||||
const content = readFileSync(transcriptPath, "utf-8")
|
||||
const pattern = new RegExp(`<promise>\\s*${escapeRegex(promise)}\\s*</promise>`, "is")
|
||||
return pattern.test(content)
|
||||
const lines = content.split("\n").filter(l => l.trim())
|
||||
|
||||
for (const line of lines) {
|
||||
try {
|
||||
const entry = JSON.parse(line)
|
||||
if (entry.type === "user") continue
|
||||
if (pattern.test(line)) return true
|
||||
} catch {
|
||||
continue
|
||||
}
|
||||
}
|
||||
return false
|
||||
} catch {
|
||||
return false
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user