@@ -150,8 +150,12 @@ jobs:
150150 `✅ No critical issues found.` and put any P2 advice underneath.
151151
152152 CRITICAL OUTPUT REQUIREMENTS:
153- 1. Return a JSON object with a single "review" field containing the
154- full markdown report.
153+ 1. Return a JSON object with a single "review" field whose VALUE
154+ is a plain markdown STRING. Do NOT put another JSON object
155+ inside the "review" string -- the workflow has observed the
156+ skill's tier-2 output looking JSON-shaped and the model
157+ wrapping it a second time, which posts raw JSON in the
158+ comment. The `review` value must be markdown text only.
155159 2. The review markdown MUST start with EXACTLY these two lines:
156160 <!-- compound-engineering-review -->
157161 ## Compound Engineering Review
@@ -173,16 +177,26 @@ jobs:
173177 direction : last
174178
175179 # fromJSON() in `with:` has been observed to leave structured_output JSON
176- # unparsed for the sibling claude-code-review workflow. Extract the
177- # review field via jq for reliability.
180+ # unparsed for the sibling claude-code-review workflow. Extract via jq.
181+ #
182+ # Defensive double-unwrap: the model has been observed to return
183+ # `{"review": "{\"review\": \"<markdown>\"}"}` -- wrapping its own JSON
184+ # output a second time when the underlying skill returns a JSON-shaped
185+ # response. Detect that case (the inner string parses as an object with
186+ # a `review` key) and unwrap once more so we post markdown, not JSON.
178187 - name : Extract review from structured output
179188 id : extract
180189 env :
181190 STRUCTURED_OUTPUT : ${{ steps.review.outputs.structured_output }}
182191 run : |
192+ REVIEW="$(printf '%s' "$STRUCTURED_OUTPUT" | jq -r '.review')"
193+ if printf '%s' "$REVIEW" | jq -e 'type == "object" and has("review")' >/dev/null 2>&1; then
194+ REVIEW="$(printf '%s' "$REVIEW" | jq -r '.review')"
195+ fi
183196 {
184197 echo 'review<<COMPOUND_REVIEW_EOF'
185- printf '%s' "$STRUCTURED_OUTPUT" | jq -r '.review'
198+ printf '%s' "$REVIEW"
199+ echo
186200 echo 'COMPOUND_REVIEW_EOF'
187201 } >> "$GITHUB_OUTPUT"
188202
0 commit comments