Skip to content

fix(skills): add dedup check for inline review comment replies - #141

Merged
max-sixty merged 2 commits into
mainfrom
hourly/review-23934042700
Apr 3, 2026
Merged

max-sixty merged 2 commits into
mainfrom
hourly/review-23934042700

Conversation

@tend-agent

@tend-agent tend-agent commented Apr 3, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add explicit dedup guidance for inline review comment replies in the running-in-ci skill
  • When replying to a review comment, the bot must now check for existing bot replies to the same in_reply_to_id before posting

Root cause: A single PR review fires both pull_request_review and pull_request_review_comment events. The handle job's concurrency group correctly serializes these runs (the second queues until the first completes). However, the existing "Recheck Before Posting" section only checks total comment/review counts — too coarse to detect that the bot already replied to a specific inline comment. The second run's finer-grained check used a non-existent GET /replies endpoint that returned a 404, and the fallback output was ambiguous, making the bot conclude "No existing replies."

Evidence: On max-sixty/worktrunk PR #1890, runs 23933934456 (pull_request_review, handle 04:34:16–04:36:35) and 23933934467 (pull_request_review_comment, handle 04:36:38–04:38:29) were correctly serialized by the concurrency group, but the second run's recheck failed to detect the first's reply and posted a duplicate.

Gate assessment:

  • Evidence level: High — structural issue (the /replies GET endpoint always 404s, making the fallback output always ambiguous)
  • Classification: Structural — deterministic cause, will recur whenever dual events fire
  • Change type: Targeted fix — adds one subsection with an explicit, correct API command
  • Prior near-miss: PRQL/prql runs 23831453414/23831453468 had the same dual-trigger but avoided duplication due to timing

Test plan

  • Verify the skill file parses correctly (valid markdown, consistent structure)
  • In future dual-event scenarios (pull_request_review + pull_request_review_comment), the second run should detect the first's reply and exit silently

🤖 Generated with Claude Code

A single PR review fires both pull_request_review and
pull_request_review_comment events, triggering concurrent tend-mention
runs. The existing "Recheck Before Posting" guidance only checks total
comment counts, which doesn't catch duplicate replies to a specific
inline comment.

Add an explicit check: before replying to a review comment, query
the PR's review comments for existing bot replies to the same
in_reply_to_id. If one exists, exit silently.

Evidence: max-sixty/worktrunk PR #1890 received two near-identical bot
replies (comment IDs 3031400525 and 3031403943) to the same review
question. The second run detected 1 existing reply but misread the
output because it used a non-existent /replies GET endpoint that 404'd,
and the fallback count was concatenated with the error JSON.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@tend-agent tend-agent added the claude-behavior Behavioral issues found by review-reviewers label Apr 3, 2026
@max-sixty

Copy link
Copy Markdown
Owner

A single PR review fires both pull_request_review and pull_request_review_comment events, triggering concurrent tend-mention runs

how does the mention concurrency check work? wouldn't it prevent multiple runs on the same PR?

@tend-agent

Copy link
Copy Markdown
Collaborator Author

Good question. The concurrency group did serialize the runs — looking at the cited worktrunk jobs, the first handle job ran 04:34:16–04:36:35 and the second started at 04:36:38. So they weren't truly concurrent.

The problem was in the second run's recheck logic. The existing "Recheck Before Posting" section checks total comment/review counts, which is too coarse to detect a reply to a specific inline comment. The second run attempted a finer-grained check but used a GET /repos/.../pulls/.../comments/{id}/replies endpoint that doesn't exist — the 404 response got concatenated with the fallback count, making it conclude "no existing replies."

So the concurrency serializes correctly; this PR fixes the recheck step so the second run can actually detect the first's reply. The PR description's "triggering concurrent workflow runs" framing is misleading — I'll update it.

### Dedup check for inline review comment replies

A single PR review can fire both `pull_request_review` and `pull_request_review_comment` events,
triggering concurrent workflow runs. Before replying to an inline review comment, check whether

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but then this is incorrect?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes — fixed in 9aca0ae. Now reads "triggering separate workflow runs (serialized by the concurrency group, not truly concurrent)."

The concurrency group serializes these runs — they aren't truly
concurrent. Fixes the misleading framing flagged in review.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@max-sixty
max-sixty merged commit 27c6210 into main Apr 3, 2026
7 checks passed
@max-sixty
max-sixty deleted the hourly/review-23934042700 branch April 3, 2026 14:25
tend-agent pushed a commit that referenced this pull request Apr 3, 2026
The LAST_REVIEW_SHA filter excluded COMMENTED reviews with empty bodies,
but these reviews carry inline comments and are substantive. This caused
redundant full re-analysis when the bot had already reviewed via inline
comments (observed in run 23949079715 on max-sixty/tend PR #141).

Co-Authored-By: Claude Opus 4.6 <[email protected]>
max-sixty pushed a commit that referenced this pull request Apr 15, 2026
## Summary

Add a dedup recheck step in `running-in-ci` for PR creation, analogous
to the existing dedup check for inline review comment replies. Re-run
`gh pr list` immediately before `gh pr create` so a concurrent sibling
run doesn't slip a duplicate PR past the initial session-start check.

## Evidence

Observed on `PRQL/prql` in runs
[24464554439](https://github.com/PRQL/prql/actions/runs/24464554439) and
[24464634498](https://github.com/PRQL/prql/actions/runs/24464634498).

Timeline:

- 15:57:00 — `max-sixty` commented "do the follow-up please" on issue
[PRQL/prql#5802](PRQL/prql#5802) (Zig 0.16
follow-up)
- 15:57:03 — `tend-mention` run A started on issue #5802
- 15:58:45 — `vanillajonathan` commented on PR
[PRQL/prql#5801](PRQL/prql#5801) asking the bot
to create a Zig 0.16 PR
- 15:58:48 — `tend-mention` run B started on PR #5801 (different
concurrency group — runs in parallel with A)
- ~16:02 — each run calls `gh pr list` once, early in its session; no
Zig fix PR exists yet
- 16:08:17 — run B calls `gh pr create` →
[PRQL/prql#5803](PRQL/prql#5803)
- 16:09:05 — run A calls `gh pr create` →
[PRQL/prql#5804](PRQL/prql#5804), 48s after
#5803 appeared; no recheck

Both PRs modify the same two files
(`.github/workflows/test-prqlc-c.yaml` to drop the `version: 0.15.2`
pin, and `prqlc/bindings/prqlc-c/examples/minimal-zig/build.zig` to move
calls onto `root_module`) with the same intent — near-duplicates
differing only in refactoring style. Maintainers must now triage and
close one.

## Root cause

`tend-mention`'s [`handle` job concurrency
group](https://github.com/max-sixty/tend/blob/main/generator/src/tend/workflows.py)
is keyed by `issue.number || pull_request.number`, so mentions on
different threads (issue #5802 vs PR #5801) run concurrently. The
current `PR Creation` guidance says to check `gh pr list` before
creating, but in practice runs do this once at session start. Minutes
pass between the check and `gh pr create`, during which a sibling run
can open a scope-overlapping PR — invisible to the stale check.

## Gate assessment

- **Confidence**: High — concrete wrong outcome (two open PRs for the
same fix) with a traced decision chain for both runs.
- **Structural vs stochastic**: **Structural**. The same conditions (two
mentions on different threads asking for the same fix within a few
minutes) will reliably reproduce this; the current guidance prescribes a
one-shot check that the race outflanks.
- **Occurrences**: 1 this run, 0 historical in
[#133](#133). Passes Gate 1
under the "one clear occurrence sufficient for structural failures"
rule.
- **Magnitude**: Targeted fix — adds a 17-line recheck section analogous
to the existing `Dedup check for inline review comment replies` pattern
merged in [#141](#141). Passes
Gate 2.

## Test plan

- [ ] Skill lint (`pre-commit run --all-files`)
- [ ] Verify the proposed `gh pr list --state open --author $BOT_LOGIN
--json number,title,headRefName,createdAt` returns what a bot can
actually use to decide (it does: standard gh flags)
- [ ] Spot-check: the next time two concurrent mentions hit different
threads asking for the same fix, only one PR should be created

Co-authored-by: continuous-bot <[email protected]>
Co-authored-by: Claude Opus 4.6 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-behavior Behavioral issues found by review-reviewers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants