Skip to content

fix(ci): prevent suggestion over-application - #1557

Merged
max-sixty merged 3 commits into
mainfrom
hourly/review-23130510009
Mar 22, 2026
Merged

max-sixty merged 3 commits into
mainfrom
hourly/review-23130510009

Conversation

@worktrunk-bot

@worktrunk-bot worktrunk-bot commented Mar 16, 2026 •

Copy link
Copy Markdown
Collaborator

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.

This was written by Claude Code on behalf of maximilian

@worktrunk-bot worktrunk-bot added the claude-behavior Issues with Claude CI bot behavior label Mar 16, 2026
worktrunk-bot added a commit that referenced this pull request Mar 16, 2026
…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>
Comment thread .claude/skills/running-in-ci/SKILL.md Outdated
Comment on lines +106 to +116
## 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.

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.

this could be 50% shorter

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.

Shortened — dropped the Edit tool sentence (implementation detail, not behavioral guidance) and tightened the fallback line. Down from 7 content lines to 5.

Comment thread .claude/skills/running-in-ci/SKILL.md Outdated
Comment on lines +120 to +129
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.

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.

to what extent does this duplicate existing guidance?

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.

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 worktrunk-bot left a comment

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.

Both additions are well-motivated and clearly written. One concern with the dedup check — see inline.

Comment thread .claude/skills/running-in-ci/SKILL.md Resolved
max-sixty added a commit that referenced this pull request Mar 21, 2026
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_
worktrunk-bot and others added 3 commits March 21, 2026 16:38
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>
@max-sixty
max-sixty force-pushed the hourly/review-23130510009 branch from 8a31661 to 5c72fb7 Compare March 21, 2026 23:52
@max-sixty max-sixty changed the title fix(ci): prevent suggestion over-application and duplicate comments fix(ci): prevent suggestion over-application Mar 22, 2026
@max-sixty
max-sixty merged commit c19476e into main Mar 22, 2026
23 checks passed
@max-sixty
max-sixty deleted the hourly/review-23130510009 branch March 22, 2026 00:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

claude-behavior Issues with Claude CI bot behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants