@@ -173,11 +173,41 @@ agents:
173173
174174 ## Posting Format (GitHub posting mode)
175175
176- Convert each CONFIRMED/LIKELY finding to an inline comment:
176+ Convert each CONFIRMED/LIKELY finding to an inline comment object for the `comments` array :
177177 ```json
178178 {"path": "file.go", "line": 123, "body": "**ISSUE**\n\nDETAILS\n\n<!-- cagent-review -->"}
179179 ```
180- Post: `echo '{"body":"## Review Summary\n\n...","event":"COMMENT","comments":[...]}' | gh api repos/{owner}/{repo}/pulls/{pr}/reviews --input -`
180+
181+ IMPORTANT: Use `jq` to construct the JSON payload. Do NOT manually build JSON strings
182+ with `echo` — this causes double-escaping of newlines (`\n` rendered as literal text).
183+
184+ Build the review body and comments, then use `jq` to produce correctly-escaped JSON:
185+ ```bash
186+ # Write the review body with real newlines (heredoc or printf)
187+ REVIEW_BODY="## Review Summary
188+
189+ ### Assessment: ...
190+
191+ ..."
192+
193+ # Start with an empty comments array
194+ echo '[]' > /tmp/review_comments.json
195+
196+ # Append each finding (loop over your confirmed/likely results)
197+ jq --arg path "$file_path" --argjson line "$line_number" \
198+ --arg body "$comment_body" \
199+ '. += [{path: $path, line: $line, body: $body}]' \
200+ /tmp/review_comments.json > /tmp/review_comments.tmp \
201+ && mv /tmp/review_comments.tmp /tmp/review_comments.json
202+
203+ # Use jq to assemble the final payload with proper escaping
204+ jq -n \
205+ --arg body "$REVIEW_BODY" \
206+ --arg event "COMMENT" \
207+ --slurpfile comments /tmp/review_comments.json \
208+ '{body: $body, event: $event, comments: $comments[0]}' \
209+ | gh api repos/{owner}/{repo}/pulls/{pr}/reviews --input -
210+ ```
181211
182212 The `<!-- cagent-review -->` marker MUST be on its own line, separated by a blank line
183213 from the content. Do NOT include it in console output mode.
0 commit comments