From fb291be57976585ff109ad99f814276ccfd1a407 Mon Sep 17 00:00:00 2001 From: carlos-alm Date: Thu, 30 Jul 2026 10:45:43 -0700 Subject: [PATCH 1/3] fix(skills): recognize Greptile's reaction as convergence, not a stall 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. --- .claude/skills/fixer/SKILL.md | 16 +++++++++++++++- .claude/skills/sweep/SKILL.md | 2 +- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.claude/skills/fixer/SKILL.md b/.claude/skills/fixer/SKILL.md index 06d4a5be0..274f586bd 100644 --- a/.claude/skills/fixer/SKILL.md +++ b/.claude/skills/fixer/SKILL.md @@ -516,7 +516,21 @@ PR=$(cat .codegraph/fixer/current-pr) gh pr checks "$PR" --repo "$REPO" --watch --interval 30 || echo "fixer: checks not all green — G5 needs work" ``` -For Greptile's review to arrive, use the `Monitor` tool to poll the comments endpoint until a `Confidence Score` appears (load it with `ToolSearch` if its schema is not present). Do not use foreground `sleep`. +For Greptile's response to a re-trigger to arrive, use the `Monitor` tool to poll (load it with `ToolSearch` if its schema is not present). Do not use foreground `sleep`. **Do not poll only for a `Confidence Score` to appear** — Greptile typically posts that score once, in its *initial* summary, and it does not 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 has converged. The actual terminal signals after posting `@greptileai` are: + +- a **new** review or comment from `greptile-apps[bot]` posted after the trigger's timestamp (new findings — go address them and re-trigger again), or +- a **positive reaction** (`+1`, `hooray`, `heart`, `rocket`) from `greptile-apps[bot]` **on the trigger comment itself**, with no follow-up review — this means Greptile examined the fix and has nothing further to flag. Treat it as convergence for this round, not a reason to keep waiting for a review object that isn't coming. + +```bash +mkdir -p .codegraph/fixer +REPO=$(cat .codegraph/fixer/repo) +PR=$(cat .codegraph/fixer/current-pr) +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" \ + --jq '[.[] | select(.user.login == "greptile-apps[bot]" and (.content == "+1" or .content == "hooray" or .content == "heart" or .content == "rocket"))] | length' +# > 0 with no new review after this comment's timestamp: converged, proceed to the gate evaluation below. +``` Evaluate the whole gate in one pass: diff --git a/.claude/skills/sweep/SKILL.md b/.claude/skills/sweep/SKILL.md index 24ea61809..334a37e03 100644 --- a/.claude/skills/sweep/SKILL.md +++ b/.claude/skills/sweep/SKILL.md @@ -336,7 +336,7 @@ If all changes were only in response to Greptile feedback, do NOT re-trigger Cla 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. 2. Fetch new comments again (repeat Step 2d + 2d.1 — re-mine the summary body too, not just inline comments). 3. If there are **new** comments from Greptile or Claude, go back to Step 2e and address them, then re-trigger per 2g **only if** the trigger-count cap in 2g hasn't already been hit. 4. **The 50-trigger cap in Step 2g is the actual stop condition — not a mental "round" count.** If you hit the cap mid-loop, stop re-triggering immediately (you may still reply to outstanding comments), run the mandatory Step 2h.1 final live check, and only then go to 2i with `Status: needs-human-review`. From 6cc99750a73535ed774795d2c833457cd9e70d18 Mon Sep 17 00:00:00 2001 From: carlos-alm Date: Sat, 1 Aug 2026 19:10:40 -0600 Subject: [PATCH 2/3] fix: correct trigger-comment lookup pagination and targeting --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. --- .claude/skills/fixer/SKILL.md | 7 +++++-- .claude/skills/sweep/SKILL.md | 10 +++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/.claude/skills/fixer/SKILL.md b/.claude/skills/fixer/SKILL.md index 274f586bd..a06f693f7 100644 --- a/.claude/skills/fixer/SKILL.md +++ b/.claude/skills/fixer/SKILL.md @@ -525,8 +525,11 @@ For Greptile's response to a re-trigger to arrive, use the `Monitor` tool to pol mkdir -p .codegraph/fixer REPO=$(cat .codegraph/fixer/repo) PR=$(cat .codegraph/fixer/current-pr) -TRIGGER_COMMENT_ID=$(gh api "repos/$REPO/issues/$PR/comments" --paginate --jq \ - '[.[] | select(.body | test("^@greptileai\\s*$"))] | last | .id') +# --paginate with --jq applies the filter per-page, not to the merged result, so 'last' +# across a multi-page comment list would return one candidate PER PAGE instead of the true +# global last — fetch raw and slurp instead, matching the pattern used elsewhere in this file. +TRIGGER_COMMENT_ID=$(gh api "repos/$REPO/issues/$PR/comments" --paginate \ + | jq -s '[.[][] | select(.body | test("^@greptileai\\s*$"))] | last | .id') gh api "repos/$REPO/issues/comments/$TRIGGER_COMMENT_ID/reactions" \ --jq '[.[] | select(.user.login == "greptile-apps[bot]" and (.content == "+1" or .content == "hooray" or .content == "heart" or .content == "rocket"))] | length' # > 0 with no new review after this comment's timestamp: converged, proceed to the gate evaluation below. diff --git a/.claude/skills/sweep/SKILL.md b/.claude/skills/sweep/SKILL.md index 334a37e03..4883b4d90 100644 --- a/.claude/skills/sweep/SKILL.md +++ b/.claude/skills/sweep/SKILL.md @@ -336,7 +336,15 @@ If all changes were only in response to Greptile feedback, do NOT re-trigger Cla 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. **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. +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** — a positive reaction (`+1`/`hooray`/`heart`/`rocket`) from `greptile-apps[bot]` there, with no new review following it, means Greptile examined the fix and has nothing further to add: a terminal "done" signal for this round on its own, so don't keep polling the full 15–30 minutes waiting for a review object that isn't coming. Look up the trigger comment **by its content**, not "the most recent non-Greptile comment" — if anything else gets posted after your trigger (another user, another agent), that lookup would silently drift to the wrong comment: + ```bash + # --paginate with --jq applies the filter per-page, not to the merged result — fetch raw + # and slurp instead, or a multi-page comment list silently misses the true global last. + trigger_id=$(gh api repos//issues//comments --paginate \ + | jq -s '[.[][] | select(.body | test("^@greptileai\\s*$"))] | last | .id') + positive_count=$(gh api repos//issues/comments/$trigger_id/reactions \ + --jq '[.[] | select(.user.login == "greptile-apps[bot]" and (.content == "+1" or .content == "hooray" or .content == "heart" or .content == "rocket"))] | length') + ``` 2. Fetch new comments again (repeat Step 2d + 2d.1 — re-mine the summary body too, not just inline comments). 3. If there are **new** comments from Greptile or Claude, go back to Step 2e and address them, then re-trigger per 2g **only if** the trigger-count cap in 2g hasn't already been hit. 4. **The 50-trigger cap in Step 2g is the actual stop condition — not a mental "round" count.** If you hit the cap mid-loop, stop re-triggering immediately (you may still reply to outstanding comments), run the mandatory Step 2h.1 final live check, and only then go to 2i with `Status: needs-human-review`. From 5ecef2ad102dca515d4537d284bef7bf9f07a7db Mon Sep 17 00:00:00 2001 From: carlos-alm Date: Sat, 1 Aug 2026 19:15:41 -0600 Subject: [PATCH 3/3] fix: capture trigger comment ID at post time instead of re-deriving it 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. --- .claude/skills/fixer/SKILL.md | 8 +++----- .claude/skills/sweep/SKILL.md | 14 +++++++------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.claude/skills/fixer/SKILL.md b/.claude/skills/fixer/SKILL.md index a06f693f7..e972920e4 100644 --- a/.claude/skills/fixer/SKILL.md +++ b/.claude/skills/fixer/SKILL.md @@ -521,15 +521,13 @@ For Greptile's response to a re-trigger to arrive, use the `Monitor` tool to pol - a **new** review or comment from `greptile-apps[bot]` posted after the trigger's timestamp (new findings — go address them and re-trigger again), or - a **positive reaction** (`+1`, `hooray`, `heart`, `rocket`) from `greptile-apps[bot]` **on the trigger comment itself**, with no follow-up review — this means Greptile examined the fix and has nothing further to flag. Treat it as convergence for this round, not a reason to keep waiting for a review object that isn't coming. +Capture the trigger comment's ID **from the post response itself** when you send it, and reuse that exact ID for the reaction check below. Do not post the trigger separately and then search for "the last `@greptileai` comment" afterward — if another trigger gets posted on the same PR in the meantime (a resumed run, a concurrent session per the Parallel Sessions rules), that search silently drifts to the wrong comment: + ```bash mkdir -p .codegraph/fixer REPO=$(cat .codegraph/fixer/repo) PR=$(cat .codegraph/fixer/current-pr) -# --paginate with --jq applies the filter per-page, not to the merged result, so 'last' -# across a multi-page comment list would return one candidate PER PAGE instead of the true -# global last — fetch raw and slurp instead, matching the pattern used elsewhere in this file. -TRIGGER_COMMENT_ID=$(gh api "repos/$REPO/issues/$PR/comments" --paginate \ - | jq -s '[.[][] | select(.body | test("^@greptileai\\s*$"))] | last | .id') +TRIGGER_COMMENT_ID=$(gh api "repos/$REPO/issues/$PR/comments" -f body="@greptileai" --jq '.id') gh api "repos/$REPO/issues/comments/$TRIGGER_COMMENT_ID/reactions" \ --jq '[.[] | select(.user.login == "greptile-apps[bot]" and (.content == "+1" or .content == "hooray" or .content == "heart" or .content == "rocket"))] | length' # > 0 with no new review after this comment's timestamp: converged, proceed to the gate evaluation below. diff --git a/.claude/skills/sweep/SKILL.md b/.claude/skills/sweep/SKILL.md index 4883b4d90..f3f7b579f 100644 --- a/.claude/skills/sweep/SKILL.md +++ b/.claude/skills/sweep/SKILL.md @@ -315,11 +315,15 @@ last_reply_id=$(gh api repos//issues//comments --paginate \ positive_count=$(gh api repos//issues/comments/$last_reply_id/reactions \ --jq '[.[] | select(.user.login == "greptile-apps[bot]" and (.content == "+1" or .content == "hooray" or .content == "heart" or .content == "rocket"))] | length') -# Step 2: If positive reaction exists → skip. Otherwise → re-trigger. +# Step 2: If positive reaction exists → skip. Otherwise → re-trigger, capturing this +# trigger's own comment ID directly from the post response — Step 2h's reaction check +# reuses this exact value rather than searching for "the last @greptileai comment", +# which would drift to a different trigger if this PR is also being worked by another +# session or agent (Parallel Sessions) before this round's poll runs. if [ "$positive_count" -gt 0 ]; then echo "Greptile already reacted positively — skipping re-trigger." else - gh api repos//issues//comments -f body="@greptileai" + trigger_id=$(gh api repos//issues//comments -f body="@greptileai" --jq '.id') fi ``` @@ -336,12 +340,8 @@ If all changes were only in response to Greptile feedback, do NOT re-trigger Cla 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. **But also check the trigger comment's own reactions on each poll** — a positive reaction (`+1`/`hooray`/`heart`/`rocket`) from `greptile-apps[bot]` there, with no new review following it, means Greptile examined the fix and has nothing further to add: a terminal "done" signal for this round on its own, so don't keep polling the full 15–30 minutes waiting for a review object that isn't coming. Look up the trigger comment **by its content**, not "the most recent non-Greptile comment" — if anything else gets posted after your trigger (another user, another agent), that lookup would silently drift to the wrong comment: +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**, reusing the `$trigger_id` you captured in Step 2g when you posted it — a positive reaction (`+1`/`hooray`/`heart`/`rocket`) from `greptile-apps[bot]` there, with no new review following it, means Greptile examined the fix and has nothing further to add: a terminal "done" signal for this round on its own, so don't keep polling the full 15–30 minutes waiting for a review object that isn't coming: ```bash - # --paginate with --jq applies the filter per-page, not to the merged result — fetch raw - # and slurp instead, or a multi-page comment list silently misses the true global last. - trigger_id=$(gh api repos//issues//comments --paginate \ - | jq -s '[.[][] | select(.body | test("^@greptileai\\s*$"))] | last | .id') positive_count=$(gh api repos//issues/comments/$trigger_id/reactions \ --jq '[.[] | select(.user.login == "greptile-apps[bot]" and (.content == "+1" or .content == "hooray" or .content == "heart" or .content == "rocket"))] | length') ```