Skip to content

Commit 3223323

Browse files
committed
fix: add anti-loop guardrail for drafter re-reading same file
Signed-off-by: Derek Misler <derek.misler@docker.com>
1 parent be76642 commit 3223323

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

review-pr/agents/pr-review.yaml

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ agents:
9797
- Write each chunk to `/tmp/drafter_chunk_N.diff` (numbered sequentially).
9898
- Delegate each chunk to the drafter separately.
9999
- Merge all findings arrays into a single list before proceeding to step 5.
100-
- Combine summaries into one overall summary.
101100
d. Include any relevant learned patterns from memory in each delegation.
102101
103102
## CRITICAL: How to delegate to the drafter
@@ -221,12 +220,8 @@ agents:
221220
222221
Build the review body and comments, then use `jq` to produce correctly-escaped JSON:
223222
```bash
224-
# Write the review body with real newlines (heredoc or printf)
225-
REVIEW_BODY="## Review Summary
226-
227-
### Assessment: ...
228-
229-
..."
223+
# Review body is just the assessment badge — findings go in inline comments
224+
REVIEW_BODY="### Assessment: 🟢 APPROVE" # or 🟡 NEEDS ATTENTION / 🔴 CRITICAL
230225
231226
# Start with an empty comments array
232227
echo '[]' > /tmp/review_comments.json
@@ -255,8 +250,6 @@ agents:
255250
```
256251
## Review: COMMENT
257252
### Assessment: [🟢 APPROVE|🟡 NEEDS ATTENTION|🔴 CRITICAL]
258-
### Summary
259-
<assessment>
260253
### Findings
261254
**[SEVERITY] file:line — issue**
262255
details
@@ -298,6 +291,16 @@ agents:
298291
Do NOT guess other file paths or search the filesystem for the diff. Read the ONE path
299292
the orchestrator gave you, or return the error above.
300293
294+
## ANTI-LOOP: Read the diff file exactly ONCE
295+
296+
After you `read_file` on the diff chunk path, you have the diff contents. Do NOT
297+
call `read_file` on the same diff chunk path again — you already have the data.
298+
Immediately proceed to analyze the diff and produce your findings JSON.
299+
300+
If you find yourself about to call `read_file` on a path you have already read,
301+
STOP and instead produce your `findings` and `summary` output with whatever
302+
context you have. Never read the same file more than twice total.
303+
301304
You also have `read_file` access for reading full source files when analyzing findings
302305
(e.g., to check imports, surrounding code, or related functions).
303306
@@ -335,6 +338,11 @@ agents:
335338
4. **Only read files referenced in the diff.** Check imports, function calls,
336339
and type references that appear in the `+` lines. Do NOT explore unrelated
337340
parts of the repository.
341+
5. **No duplicate reads.** Never call `read_file` on the same path more than
342+
twice. If you have already read a file, use the content from your previous
343+
read. For the diff chunk file specifically (`/tmp/drafter_chunk_*.diff`),
344+
read it exactly once — a second read means you are looping. For source
345+
files, skip the duplicate and continue verifying remaining findings.
338346
339347
## CRITICAL RULE: Only Review Changed Code
340348
@@ -461,7 +469,7 @@ agents:
461469
summary:
462470
type: string
463471
description: Brief overall assessment of the diff quality
464-
required: ["findings", "summary"]
472+
required: ["findings"]
465473
additionalProperties: false
466474

467475
toolsets:

0 commit comments

Comments
 (0)