Repository navigation
fix(ci): prevent suggestion over-application - #1557
Conversation
…ling Recurrence #3 of #1350 / #1430. The review-pr skill directed bots to "skip to step 5" for silent self-authored PRs, but step 5 had no skip condition — so bots entered 10-minute CI polling loops that add no value (no approval to dismiss on failure). Fix: redirect self-authored silent verdicts to step 6 (resolve threads) and add an explicit early-return at the top of step 5. Evidence from runs 23131628298 and 23130657242: both spent ~10 minutes polling CI on self-authored PRs #1558 and #1557 respectively, with no action possible on the results. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
| ## Applying GitHub Suggestions | ||
|
|
||
| When a reviewer posts a GitHub suggestion (`suggestion` code block), apply it | ||
| with exact scope — change only the lines the suggestion covers. Do not | ||
| reinterpret the suggestion's intent or extend it to adjacent lines. Use the | ||
| `Edit` tool with an `old_string` that matches **only** the lines the suggestion | ||
| targets, not surrounding context. | ||
|
|
||
| If the suggestion seems incomplete or you think more lines should change, apply | ||
| the literal suggestion first and note the potential further improvement in your | ||
| reply. |
There was a problem hiding this comment.
Shortened — dropped the Edit tool sentence (implementation detail, not behavioral guidance) and tightened the fallback line. Down from 7 content lines to 5.
| Before posting a comment, check for recent bot comments on the same | ||
| PR/issue to avoid duplicates from concurrent runs: | ||
|
|
||
| ```bash | ||
| gh api repos/{owner}/{repo}/issues/{number}/comments \ | ||
| --jq '.[] | select(.user.login == "{bot_login}") | {id, created_at, body: (.body | .[0:100])}' | ||
| ``` | ||
|
|
||
| If you already commented on the same topic within the last 5 minutes, do not | ||
| post again. |
There was a problem hiding this comment.
to what extent does this duplicate existing guidance?
There was a problem hiding this comment.
The review-pr skill has dedup logic, but it's specific to flaky test issue comments (editing an existing bot comment on a tracking issue). This one targets a different scenario: concurrent claude-mention runs both responding to the same issue_comment event and posting near-identical PR comments seconds apart.
That said, if you think the pattern is general enough that skills should just know to check, happy to drop this and rely on convention.
worktrunk-bot
left a comment
There was a problem hiding this comment.
Both additions are well-motivated and clearly written. One concern with the dedup check — see inline.
The `claude-code-action` defaults `trigger_phrase` to `@claude`. When `claude-review.yaml` handled `pull_request_review` events on bot-authored PRs, it passed an empty prompt (`''`), causing the action to fall back to trigger detection — which looked for `@claude` in the review text. Since nobody writes `@claude` in reviews, the action always skipped. This meant formal reviews on bot-authored PRs were silently ignored by `claude-review` (only handled incidentally via `claude-mention`'s `pull_request_review_comment` path when inline comments were present). Two fixes: - Set `trigger_phrase: "@worktrunk-bot"` in both interactive workflows (`claude-review`, `claude-mention`) so the action never defaults to `@claude` - Provide a non-empty prompt for the `pull_request_review` path in `claude-review.yaml`, so the action runs the prompt directly instead of falling back to trigger detection The five automated workflows (ci-fix, hourly, nightly, renovate, triage) are unchanged — they all provide explicit prompts, making `trigger_phrase` irrelevant. Evidence from PR #1557: run 23132865052 logged `No trigger was met for @claude` / `Context prompt: NO PROMPT` / `No trigger found, skipping remaining steps` despite the workflow's `if:` condition correctly selecting the event. > _This was written by Claude Code on behalf of @max-sixty_
Two behavioral issues from this hour's runs: 1. Bot used Edit to replace 3 lines with 1 when a GitHub suggestion only asked to change one word on one line (run 23129611560 on PR #1548). Add guidance to apply suggestions with exact scope. 2. Two concurrent claude-mention runs both commented on PR #1281 within 17 seconds (runs 23129315322, 23129320855). Add a dedup check before posting comments. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Drop implementation detail about Edit tool and tighten wording. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address review feedback on #1557: - "this could be 50% shorter": compressed suggestion section from 8 lines to 2 - "to what extent does this duplicate existing guidance?": removed the dedup check entirely — review-pr already covers concurrent-run dedup (SKILL.md:76-81) Co-Authored-By: Claude <noreply@anthropic.com>
8a31661 to
5c72fb7
Compare
The bot was over-applying GitHub suggestions — a one-word edit on one line caused the bot to replace three lines, deleting follow-up content the suggestion never touched (observed on PR #1548, run 23129611560).
Adds a two-line "Applying GitHub Suggestions" section to running-in-ci: apply the literal suggestion only, note broader improvements separately.
The original PR also added a dedup check for concurrent bot comments, but that duplicates existing guidance in review-pr (lines 76–81), so it was dropped per review feedback.