Skip to content

Commit 724b3f7

Browse files
authored
fix(review-pr): schema mismatch, chunk size, and timeout diagnostics (#202)
1 parent 600f396 commit 724b3f7

2 files changed

Lines changed: 41 additions & 8 deletions

File tree

review-pr/action.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ runs:
284284
echo "chunk_manifest=$(jq -nc --argjson f "$FILES" '{"1": $f}')" >> $GITHUB_OUTPUT
285285
echo "✅ Single chunk ($TOTAL_LINES lines)"
286286
else
287-
# Large diff — split at file boundaries, targeting ~1000 lines per chunk
287+
# Large diff — split at file boundaries, targeting ~600 lines per chunk
288288
CHUNK=1
289289
CHUNK_LINES=0
290290
CURRENT_FILE=""
@@ -301,9 +301,9 @@ runs:
301301
DIR=$(dirname "$FILE")
302302
303303
# Start new chunk if:
304-
# - over soft limit (1000 lines) and directory changed, OR
304+
# - over soft limit (600 lines) and directory changed, OR
305305
# - over hard limit (2000 lines) regardless of directory
306-
if ([ "$CHUNK_LINES" -gt 1000 ] && [ "$DIR" != "$CURRENT_DIR" ]) || [ "$CHUNK_LINES" -gt 2000 ]; then
306+
if ([ "$CHUNK_LINES" -gt 600 ] && [ "$DIR" != "$CURRENT_DIR" ]) || [ "$CHUNK_LINES" -gt 2000 ]; then
307307
# Save current chunk's file list to manifest
308308
MANIFEST=$(echo "$MANIFEST" | jq --argjson files "$CHUNK_FILES" --arg k "$CHUNK" '.[$k] = $files')
309309
CHUNK=$((CHUNK + 1))
@@ -326,7 +326,7 @@ runs:
326326
327327
echo "chunk_count=$CHUNK" >> $GITHUB_OUTPUT
328328
echo "chunk_manifest=$(echo "$MANIFEST" | jq -c .)" >> $GITHUB_OUTPUT
329-
echo "✅ Split into $CHUNK chunks (target ~1000 lines each)"
329+
echo "✅ Split into $CHUNK chunks (target ~600 lines each)"
330330
331331
for i in $(seq 1 $CHUNK); do
332332
LINES=$(wc -l < /tmp/drafter_chunk_${i}.diff | tr -d ' ')
@@ -806,6 +806,7 @@ runs:
806806
run: |
807807
REVIEW_URL="https://github.com/$REPOSITORY/pull/$PR_NUMBER"
808808
echo "review-url=$REVIEW_URL" >> $GITHUB_OUTPUT
809+
TIMEOUT_NOTE=""
809810
810811
if [ "$SKIP_REASON" = "concurrent" ]; then
811812
# Stay silent — the 👀 reaction on the triggering comment (added by the
@@ -814,6 +815,17 @@ runs:
814815
STATUS="⏭️ **Review skipped** — another review is already in progress"
815816
elif [ -z "$EXIT_CODE" ]; then
816817
STATUS="⏭️ **Review skipped** — agent did not run"
818+
elif [ "$EXIT_CODE" = "124" ]; then
819+
# Timeout (SIGKILL after 1800 s) — provide actionable guidance
820+
STATUS="⏱️ **Review timed out** (exit code: 124, limit: 1800 s)"
821+
TIMEOUT_NOTE="- **Exit code:** 124 (SIGKILL — 1800 s timeout)
822+
- **Timeout limit:** 1800 s
823+
- Verbose log artifact (${VERBOSE_LOG_FILE}) uploaded for debugging."
824+
if ! gh api "repos/$REPOSITORY/issues/$PR_NUMBER/comments" \
825+
-f body="⏱️ **PR Review Timed Out** — The review agent hit the 1800 s time limit before completing. This usually happens on large or complex diffs. You can re-trigger with \`/review\` — if it times out again, consider splitting the PR into smaller pieces." \
826+
2>&1; then
827+
echo "::warning::Failed to post timeout comment to PR"
828+
fi
817829
elif [ "$EXIT_CODE" != "0" ]; then
818830
# Check if agent actually posted a review despite the error exit code.
819831
# This happens when a sub-agent fails (e.g., API overload) but the root
@@ -841,6 +853,10 @@ runs:
841853
echo "## PR Review Summary"
842854
echo ""
843855
echo "$STATUS"
856+
if [ -n "$TIMEOUT_NOTE" ]; then
857+
echo ""
858+
printf '%s\n' "$TIMEOUT_NOTE"
859+
fi
844860
echo ""
845861
echo "📝 [View Pull Request #$PR_NUMBER]($REVIEW_URL)"
846862
} >> $GITHUB_STEP_SUMMARY

review-pr/agents/pr-review.yaml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,8 @@ agents:
155155
c. Delegate to the drafter once with the path `./pr-review.diff`.
156156
157157
**Both modes**:
158-
d. Merge all findings arrays into a single list before proceeding.
158+
d. Merge all findings arrays into a single list before proceeding. Each finding
159+
object uses fields `category`, `issue`, `details`, `in_diff` — not `title`/`body`.
159160
e. Include any relevant learned patterns from memory in each delegation.
160161
161162
## CRITICAL: How to delegate to the drafter
@@ -170,12 +171,26 @@ agents:
170171
- File history: relevant entries from `/tmp/file_history.txt` (CI mode only — skip in console mode)
171172
- Available files: run `ls` on directories of changed files so drafter knows real paths
172173
- Learned patterns: any relevant memories
174+
175+
**CRITICAL — drafter response schema (schema-validated, strict):**
176+
The drafter returns a JSON object with these exact top-level fields:
177+
- `findings`: array of objects with fields `file`, `line`, `severity`, `category`,
178+
`issue` (one-line summary), `details` (trigger + impact), `in_diff` (boolean)
179+
- `summary`: string — overall assessment
180+
- `review_complete`: boolean — true if the full chunk was reviewed
181+
182+
**NEVER mention `title` or `body` as finding field names in the delegation
183+
message.** Those fields do not exist in the drafter schema. If the task string
184+
asks for `title`/`body`, the schema validator rejects every emit attempt and the
185+
drafter enters an infinite file-read retry loop. Always use `issue` and `details`.
173186
5. Parse the drafter's JSON response. Check `review_complete`:
174187
- If `review_complete` is `true` AND zero findings → skip directly to step 8 (Decision Rules).
175188
- If `review_complete` is `false` AND zero findings → the drafter likely exhausted its context.
176189
Post a COMMENT review noting the review was incomplete and do NOT approve.
177-
- Otherwise, collect all findings with severity "high" or "medium"
178-
and delegate them to the `verifier` in a single batch. Skip verification for "low" findings.
190+
- Otherwise, collect all findings with severity "high" or "medium" — reference
191+
each finding's one-line summary via the `issue` field and its explanation via
192+
the `details` field (not `title`/`body`) — and delegate them to the `verifier`
193+
in a single batch. Skip verification for "low" findings.
179194
Include the project context (from step 2) in the verifier delegation so it can validate
180195
findings against project-specific conventions (e.g., language version, available APIs).
181196
**The verifier has no file access — you must provide all code context inline.**
@@ -194,7 +209,9 @@ agents:
194209
`in_changed_code == false` or `in_diff == false`.
195210
7. **Verify line numbers** before posting (see below)
196211
8. Apply the Decision Rules (see below) to determine the review verdict
197-
9. Build inline comments from CONFIRMED/LIKELY issues and post the review
212+
9. Build inline comments from CONFIRMED/LIKELY issues using each finding's `issue`
213+
(one-line summary), `details` (full explanation), `severity`, `category`, `file`,
214+
and `line` fields. Post the review.
198215
10. Always report ALL HIGH severity bugs. Limit MEDIUM/LOW to 5 comments max.
199216
200217
Find **real bugs in the changed code**, not style issues. If the changed code works correctly, approve it.

0 commit comments

Comments
 (0)