Skip to content

Commit ff37e9f

Browse files
sylvansysclaude
andcommitted
fix: Extract JSON from all assistant messages, not just last
Claude Code may output text in multiple turns. The JSON result could be in any message, not necessarily the last one. Join all text content and search for the JSON block in the combined output. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0994a1c commit ff37e9f

2 files changed

Lines changed: 8 additions & 18 deletions

File tree

.github/actions/code-quality-reviewer/action.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,10 @@ runs:
158158
159159
EXEC="${{ steps.review.outputs.execution_file }}"
160160
if [ -f "$EXEC" ]; then
161-
TEXT=$(jq -r '[.[] | select(.type=="assistant") | .message.content[]? | select(.type=="text") | .text] | last // ""' "$EXEC" 2>/dev/null || echo "")
162-
JSON=$(echo "$TEXT" | sed -n '/```json/,/```/{/```/d;p;}' | head -50)
161+
# Get ALL text from assistant messages, joined together
162+
ALL_TEXT=$(jq -r '[.[] | select(.type=="assistant") | .message.content[]? | select(.type=="text") | .text] | join("\n")' "$EXEC" 2>/dev/null || echo "")
163+
# Extract JSON block from anywhere in the combined text
164+
JSON=$(echo "$ALL_TEXT" | sed -n '/```json/,/```/{/```/d;p;}' | head -100)
163165
if echo "$JSON" | jq . >/dev/null 2>&1; then
164166
# Count checks by status
165167
CHECKS_PASSED=$(echo "$JSON" | jq '[.checks[]? | select(.status == "passed")] | length')

.github/actions/requirements-reviewer/action.yml

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -186,18 +186,11 @@ runs:
186186
RESULT='{"checks":[],"message":"Review failed to complete"}'
187187
188188
EXEC="${{ steps.review.outputs.execution_file }}"
189-
echo "::group::Debug extraction"
190-
echo "EXEC path: $EXEC"
191-
echo "File exists: $([ -f "$EXEC" ] && echo yes || echo no)"
192189
if [ -f "$EXEC" ]; then
193-
echo "File size: $(wc -c < "$EXEC") bytes"
194-
TEXT=$(jq -r '[.[] | select(.type=="assistant") | .message.content[]? | select(.type=="text") | .text] | last // ""' "$EXEC" 2>/dev/null || echo "")
195-
echo "TEXT length: ${#TEXT} chars"
196-
echo "TEXT preview: ${TEXT:0:200}"
197-
JSON=$(echo "$TEXT" | sed -n '/```json/,/```/{/```/d;p;}' | head -50)
198-
echo "JSON length: ${#JSON} chars"
199-
echo "JSON preview: ${JSON:0:200}"
200-
echo "::endgroup::"
190+
# Get ALL text from assistant messages, joined together
191+
ALL_TEXT=$(jq -r '[.[] | select(.type=="assistant") | .message.content[]? | select(.type=="text") | .text] | join("\n")' "$EXEC" 2>/dev/null || echo "")
192+
# Extract JSON block from anywhere in the combined text
193+
JSON=$(echo "$ALL_TEXT" | sed -n '/```json/,/```/{/```/d;p;}' | head -100)
201194
if echo "$JSON" | jq . >/dev/null 2>&1; then
202195
# Count checks by status
203196
CHECKS_PASSED=$(echo "$JSON" | jq '[.checks[]? | select(.status == "passed")] | length')
@@ -212,12 +205,7 @@ runs:
212205
fi
213206
214207
RESULT=$(echo "$JSON" | jq -c '.')
215-
echo "Extraction succeeded: passed=$PASSED, checks_passed=$CHECKS_PASSED"
216-
else
217-
echo "JSON parsing failed"
218208
fi
219-
else
220-
echo "Execution file not found"
221209
fi
222210
223211
# Always output

0 commit comments

Comments
 (0)