From a778db373928a1129901ac1d6b1e1184d61da890 Mon Sep 17 00:00:00 2001 From: John Kattenhorn Date: Fri, 17 Apr 2026 15:02:29 +0100 Subject: [PATCH] =?UTF-8?q?fix(run):=20raise=20review=20findings=20JSON=20?= =?UTF-8?q?cap=205000=E2=86=9220000=20chars?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The review loop parser truncates the extracted REVIEW_FINDINGS JSON to 5000 chars before handing it to jq for validation. In practice any review with 5+ detailed findings (each with a non-trivial `suggestion` field) exceeds 5000, getting cut mid-object, and then failing jq's syntax check. The only user-visible signal is a WARN line in ralph.log: Review findings JSON is malformed — skipping Findings are silently dropped, never reach the next implementation loop, and Ralph never acts on them. Observed in a real project with `REVIEW_MODE=ultimate` and a project-specific REVIEW_PROMPT.md: 4 of 6 reviews lost their output this way (loops producing 5073, 5546, 5931, 5500 chars of JSON — all just over the cap). 20000 chars (≈8–12 detailed findings) gives comfortable headroom for richer review prompts while keeping the cap in place as a safety rail against a runaway Claude response. No behavior change for smaller reviews. Also applies to the fallback extraction path (when the first sed does not find the markers in the raw file and we extract via `jq -r .result`). --- ralph/ralph_loop.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ralph/ralph_loop.sh b/ralph/ralph_loop.sh index f456918..ba7a4e8 100644 --- a/ralph/ralph_loop.sh +++ b/ralph/ralph_loop.sh @@ -1710,13 +1710,13 @@ run_review_loop() { local findings_json="" # Extract JSON between ---REVIEW_FINDINGS--- and ---END_REVIEW_FINDINGS--- markers - findings_json=$(sed -n '/---REVIEW_FINDINGS---/,/---END_REVIEW_FINDINGS---/{//!p;}' "$review_output_file" 2>/dev/null | tr -d '\n' | head -c 5000) + findings_json=$(sed -n '/---REVIEW_FINDINGS---/,/---END_REVIEW_FINDINGS---/{//!p;}' "$review_output_file" 2>/dev/null | tr -d '\n' | head -c 20000) # If output is JSON format, try extracting from result field first if [[ -z "$findings_json" ]]; then local raw_text raw_text=$(jq -r '.result // .content // ""' "$review_output_file" 2>/dev/null || cat "$review_output_file" 2>/dev/null) - findings_json=$(echo "$raw_text" | sed -n '/---REVIEW_FINDINGS---/,/---END_REVIEW_FINDINGS---/{//!p;}' 2>/dev/null | tr -d '\n' | head -c 5000) + findings_json=$(echo "$raw_text" | sed -n '/---REVIEW_FINDINGS---/,/---END_REVIEW_FINDINGS---/{//!p;}' 2>/dev/null | tr -d '\n' | head -c 20000) fi if [[ -n "$findings_json" ]]; then