Repository navigation
fix(skills): recognize Greptile's reaction as convergence, not a stall - #2195
Conversation
fixer Phase 2f and sweep Step 2h both told the agent to keep waiting for a new Greptile review after a re-trigger, with no way to recognize that a positive reaction on the trigger comment itself (with no follow-up review) means Greptile already examined the fix and has nothing further to flag.
| TRIGGER_COMMENT_ID=$(gh api "repos/$REPO/issues/$PR/comments" --paginate --jq \ | ||
| '[.[] | select(.body | test("^@greptileai\\s*$"))] | last | .id') | ||
| gh api "repos/$REPO/issues/comments/$TRIGGER_COMMENT_ID/reactions" \ |
There was a problem hiding this comment.
Paginated lookup corrupts trigger ID
When a PR's issue comments span multiple API pages, --jq evaluates last separately for each page and captures multiple IDs or null values in TRIGGER_COMMENT_ID, producing an invalid reactions URL and preventing the fixer from recognizing Greptile's convergence reaction.
There was a problem hiding this comment.
Fixed — the --paginate --jq combo applies the jq filter per-page rather than to the merged result, so last over a multi-page comment list would return one candidate per page instead of the true global last. Switched to fetching raw with --paginate and slurping with jq -s, matching the pattern this same file already uses elsewhere (e.g. the G2 unanswered-comments check a few lines below).
| After re-triggering: | ||
|
|
||
| 1. Poll for new reviews on an interval — see "Before you start: how to wait." Do not end your turn to wait passively, and don't declare a round "done" from a single check taken right after triggering — Greptile can take 15–30 minutes to respond. | ||
| 1. Poll for new reviews on an interval — see "Before you start: how to wait." Do not end your turn to wait passively, and don't declare a round "done" from a single check taken right after triggering — Greptile can take 15–30 minutes to respond. **But also check the trigger comment's own reactions on each poll**, using the same reaction check as Step 2g's Step 1 (positive reaction from `greptile-apps[bot]` — `+1`/`hooray`/`heart`/`rocket` — on the `@greptileai` comment you just posted). A positive reaction there with no new review following it means Greptile examined the fix and has nothing further to add — that is a terminal "done" signal for this round on its own; don't keep polling the full 15–30 minutes waiting for a review object that isn't coming. |
There was a problem hiding this comment.
Reaction check targets wrong comment
When another user or agent comment follows the @greptileai trigger, the referenced Step 2g lookup selects that latest non-Greptile comment instead of the trigger, causing the sweep either to miss Greptile's convergence reaction or to accept an unrelated reaction as convergence.
There was a problem hiding this comment.
Fixed — replaced the reference to Step 2g's "most recent non-Greptile comment" lookup (which drifts to the wrong comment if anything else is posted after the trigger) with a self-contained lookup keyed on the trigger comment's own content (matching ^@greptileai\s*$), plus the same paginate/slurp fix as the other finding.
Greptile SummaryUpdates the Greptile convergence workflow:
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the current instructions capture and reuse the exact trigger comment ID rather than reconstructing it through a paginated or concurrency-sensitive lookup. Important Files Changed
Reviews (3): Last reviewed commit: "fix: capture trigger comment ID at post ..." | Re-trigger Greptile |
--paginate with --jq applies per-page, so 'last' across a multi-page comment list returned one candidate per page instead of the true global last. Also replace sweep's reliance on "most recent non-Greptile comment" (which drifts to the wrong comment if anything else is posted after the trigger) with a lookup keyed on the trigger comment's own content.
| | jq -s '[.[][] | select(.body | test("^@greptileai\\s*$"))] | last | .id') | ||
| positive_count=$(gh api repos/<repo>/issues/comments/$trigger_id/reactions \ |
There was a problem hiding this comment.
Trigger lookup drifts between rounds
When another identical @greptileai comment is posted after this sweep round's trigger but before its next poll, selecting the global last matching comment checks the other trigger's reactions. This can falsely declare convergence from an unrelated reaction or miss the reaction on the current trigger and continue polling.
There was a problem hiding this comment.
Fixed — the real fix is to capture the trigger comment's ID directly from the post response (gh api ... -f body="@greptileai" --jq '.id') rather than re-deriving it afterward via any content-based search. That eliminates the drift risk entirely: Step 2g now captures trigger_id at post time, and Step 2h's reaction check reuses that exact value instead of searching for "the last @greptileai comment" (which is what both this finding and the earlier pagination finding were really pointing at).
There was a problem hiding this comment.
That's the right fix. Capturing trigger_id at post time eliminates both the drift and the pagination issues simultaneously — no content search to go stale.
One small thing worth confirming: gh api ... --jq '.id' on the comment creation endpoint returns the ID as a bare number, so $trigger_id will be an integer. That's fine for the subsequent repos/<repo>/issues/comments/$trigger_id/reactions call — just making sure neither the instruction text nor any downstream usage wraps it in quotes in a way that would break interpolation.
The fix is correct and addresses the original concern cleanly.
There was a problem hiding this comment.
Confirmed fine — $(gh api ... --jq '.id') returns a bare integer, and bash interpolates that identically whether $trigger_id is quoted or unquoted (no whitespace/special characters to worry about, unlike interpolating arbitrary strings). Neither snippet wraps it in quotes anywhere it would matter, so no further change needed.
Searching for "the last @greptileai comment" after the fact drifts to the wrong comment if another trigger lands on the same PR in between (a resumed run, a concurrent session). Capturing the ID directly from the post response removes the ambiguity entirely.
Summary
/fixer(Phase 2f) and/sweep(Step 2h) told the agent to wait for Greptile's response after posting an@greptileaire-trigger, but neither had a way to recognize that a positive reaction (+1/hooray/heart/rocket) fromgreptile-apps[bot]on the trigger comment itself — with no follow-up review — means Greptile examined the fix and has nothing further to flag./fixerPhase 2f's G1 instructions also told the agent to poll "until aConfidence Scoreappears," but Greptile typically posts that score once, in its initial summary — it doesn't necessarily reappear on later reviews, so that condition can already be trivially satisfied from round 1 while giving no signal about whether a re-trigger actually converged./sweep) to both skills' post-trigger wait logic, plus a copy-pasteablegh apisnippet in/fixerso future runs check reactions directly instead of inventing an ad hoc "wait for a new review" polling loop.Verification
SKILL.md).npm run lint— clean.Closes #2194