Skip to content

fix(mention): skip no-op tend-mention session on bot's own comments - #751

Merged
max-sixty merged 2 commits into
mainfrom
daily/review-runs-28505815799
Jul 16, 2026
Merged

max-sixty merged 2 commits into
mainfrom
daily/review-runs-28505815799

Conversation

@tend-agent

@tend-agent tend-agent commented Jul 1, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

tend-mention's verify gate has no self-loop guard for the bot's own comments. The existing bot-comment guard added in #608 only catches GitHub App / Bot accounts (github.event.comment.user.type == "Bot"); tend's bot is a PAT-based User account, so its own comments fall through to the engagement heuristics — either the bot-authored-issue short-circuit (ISSUE_AUTHOR == bot) or "bot has prior comments" — and reach the handle job, which then exits silently via the prompt's self-loop guard. A full agent session is spun up for nothing.

#608 explicitly noted this gap and left it: "Tend's own bot accounts are PAT-based user accounts (user.type == "User"), so this does not affect tend-on-tend behavior." The skill-level guard catches it, but only after paying for the session.

Evidence

Observed every review-runs window and recorded in the June tracking issue (#646). The clearest recurring trigger is the monthly tracking-issue rollover: review-reviewers creates its month's tracking issue and posts one evidence-gist link comment per repo on it, each firing a self-loop tend-mention run.

The same shape also fires from pull_request_review_comment edits (subscribed for edited), which is why the guard covers that event too — closing #756.

Fix

Add a guard in the verify script that skips comment events authored by the bot itself:

if { [ "$EVENT_NAME" = "issue_comment" ] || [ "$EVENT_NAME" = "pull_request_review_comment" ]; } \
   && [ "$COMMENT_AUTHOR" = "<bot_name>" ]; then
  echo "should_run=false" >> "$GITHUB_OUTPUT"
  exit 0
fi

COMMENT_AUTHOR is newly wired from github.event.comment.user.login.

Placed before the @<bot> mention check: a bot comment that quotes a prior @-mention would re-match the mention check and escape an after-placed guard, and there is no legitimate self-summons — the bot responding to its own mention is precisely the loop this guard breaks. It covers both comment event types that take the engagement path (issue_comment and pull_request_review_comment). The pull_request_review self-review paths carry intentional actionable-signal handling (the empty-body-APPROVED gate from #166/#608) and are left untouched.

Policy reconciliation

Per the maintainer decision on the flagged policy conflict, the review-reviewers skill's tend-mention non-issue is narrowed: a deterministic verify-gate skip of the bot's own comments is now the accepted shape (it suppresses no legitimate work), distinct from the authorship-keyed guards still rejected for tend-review (where the bot's fix-push must be re-reviewed). The review-runs and review skills don't carry an echo of that rule, so no further edits were needed there.

Testing

  • test_mention_verify_skips_self_authored_comments asserts the guard is generated, COMMENT_AUTHOR is wired, the guard covers both issue_comment and pull_request_review_comment, and it sits before the mention check and before the bot-authored-issue short-circuit.
  • test_mention_self_comment_skip_spares_review_submissions pins the carve-out: the skip is scoped to comment events and must not extend to the pull_request_review submission, so a bot self-review (which the prompt actions per fix: respond to actionable bot self-reviews instead of self-loop-exiting #762) still reaches the actionable path. Guards against a later "skip self-authored reviews too" edit silently breaking the review → fix loop.
  • Regenerated the mention regression snapshots; the guard now documents the deliberate pull_request_review boundary in-line.
  • Full generator suite: 275 passed.

Closes #756

@tend-agent tend-agent added the review-runs Findings from review-runs skill label Jul 1, 2026

@tend-agent tend-agent 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.

One scope gap worth a note (self-review): the guard fires only on issue_comment, but pull_request_review_comment (subscribed here for edited only) is the other event that carries github.event.comment.*, and a bot's own edited inline comment on a PR where it already has engagement takes the same generic-heuristic path (lines 166–181) into a no-op handle session. COMMENT_AUTHOR is already populated for that event, and the @-mention check on line 80 runs first, so a self-summons stays honored — extending the condition to [ "$EVENT_NAME" = "issue_comment" ] || [ "$EVENT_NAME" = "pull_request_review_comment" ] closes it for free.

Frequency is near-zero (the bot rarely edits its own inline comments, and created isn't subscribed), so this isn't a blocker — but the PR body groups this path under the "pull_request_review self-review paths [that] carry intentional actionable-signal handling," which isn't quite accurate: pull_request_review_comment has no such handling, it just falls through to the engagement heuristics. Worth either extending the guard or documenting the deliberate exclusion.

@tend-agent

Copy link
Copy Markdown
Collaborator Author

Flagging a standing-guidance conflict for a maintainer to reconcile before this lands — not a blocker.

This PR's guard keys on comment authorship (COMMENT_AUTHOR == <bot>), which is the shape tend's own review-reviewers non-issues list currently rules not the accepted shape. That entry names this exact scenario (the tracking-issue rollover self-loop, and the pull_request_review mirror variant) and says: "sender-based or commenter-based filters on tend-mention are not the accepted shape — they are the same authorship-keyed-guard pattern rejected for tend-review. The accepted shape for loop-prevention is a label-based skip … propose new filters only when there's a distinct loop risk that can't be expressed with a label."

Worth a maintainer decision because there's a real tension the reviewing bots didn't surface: the tend-review note above endorsed the guard and proposed broadening it, without referencing the standing ruling.

The reconciliation both ways
  • Toward label-based (the documented shape): the highest-frequency trigger cited here — the monthly tracking-issue rollover — is fully label-expressible today: the issues carry review-reviewers-tracking / review-runs-tracking. A skip on those labels covers that subset without an authorship key.
  • Toward keeping this guard: the general case ("bot comments on any thread it already participates in") isn't label-expressible, and the prompt's self-conversation guard already no-ops these — so a issue_comment && author == bot skip arguably suppresses zero legitimate work and is a pure cost optimization, which is a fair argument the non-issue doesn't fully rebut.

Either way it's a maintainer call: relax/scope the non-issue to bless this optimization, or land a label-based skip and add the ruling to the review-runs and review skills (neither of which carries it today, which is why the guard was proposed and endorsed without the conflict being noticed).

Surfaced by the hourly review-reviewers outcome audit; full evidence trail in the run's evidence gist.

@max-sixty

Copy link
Copy Markdown
Owner

@tend-agent Decision on the policy conflict you flagged: the deterministic skip is accepted here. Skipping the bot's own comments suppresses no legitimate work (unlike authorship-keyed guards on tend-review, where the bot's fix-push must still be re-reviewed), the verify script already carries authorship-keyed gates of the same shape (the Bot-type check, the empty-body-APPROVED gate), and CLAUDE.md's "Actions gate whether the agent runs at all" endorses exactly this kind of cheap YAML gate. Please rework:

  1. Move the guard before the @-mention check. A bot comment that quotes a prior @-mention (the shape in tend-mention: review-runs tracking-issue comment edit self-triggers a daily no-op session (User-type PAT bot escapes the #606 skip) #756) re-matches the mention check and escapes an after-placed guard, and there is no legitimate self-summons: the bot responding to its own mention is the loop this guard exists to break. Update the template comment and the ordering assertion in test_mention_verify_skips_self_authored_comments.

  2. Cover pull_request_review_comment too. It's subscribed for edited and takes the same engagement-heuristic path; extend the guard's event condition.

  3. Narrow the review-reviewers skill's non-issue (the tend-mention bullet under "Non-issues") so it no longer rejects this shape: authorship-keyed guards remain rejected for tend-review, but a deterministic verify-gate skip of the bot's own comments on tend-mention is accepted. Check the other skills for echoes of the same rule.

  4. Rebase onto main (the branch predates fix: respond to actionable bot self-reviews instead of self-loop-exiting #762's mention-prompt change) and regenerate the mention snapshots.

With the before-mention ordering this fully closes #756, so add Closes #756 to the PR body.

This was written by Claude Code on behalf of max

The verify gate's bot-comment guard (#608) only catches GitHub App /
Bot accounts via comment.user.type == "Bot". Tend's bot is a PAT-based
User account, so its own comments fall through to the engagement
heuristics and spin up a handle session that exits silently — pure
waste. This recurs on the monthly tracking-issue rollover, where
review-reviewers posts evidence-gist links on its own tracking issue.

Add a guard skipping self-authored issue_comment events, wired from
github.event.comment.user.login. Scoped to issue_comment so the
pull_request_review self-review paths keep their intentional
actionable-signal handling.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@tend-agent
tend-agent force-pushed the daily/review-runs-28505815799 branch from 9a42e21 to b348cb6 Compare July 14, 2026 23:02
@tend-agent

Copy link
Copy Markdown
Collaborator Author

Reworked and pushed all four:

  1. Guard moved before the @-mention check — a bot comment quoting a prior @-mention no longer escapes it, and the comment/ordering assertion in test_mention_verify_skips_self_authored_comments now asserts self_guard_idx < mention_idx.
  2. pull_request_review_comment covered — the guard's event condition is now issue_comment || pull_request_review_comment; both carry comment.user.login. Test asserts both.
  3. review-reviewers non-issue narrowed — the tend-mention bullet now blesses a deterministic verify-gate skip of the bot's own comments while keeping authorship-keyed guards rejected for tend-review (where the fix-push must still be re-reviewed). Checked review-runs and review for echoes — neither carries the rule, so no other edits.
  4. Rebased onto main (past fix: respond to actionable bot self-reviews instead of self-loop-exiting #762/fix: update sandbox_levers regtest snapshot for #762 prompt change #775) and regenerated the mention snapshots.

Added Closes #756 to the PR body. Full generator suite: 274 passed.

The self-authored-comment guard is scoped to comment events; a bot
self-review arrives as a pull_request_review submission, which stays on
the actionable path (the prompt actions self-reviews, #762). Add a
regression test that fails if the skip is ever extended to the review
submission event, and state the deliberate boundary at the guard so a
later "skip self-authored reviews too" edit doesn't silently break the
review -> fix loop.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
@max-sixty
max-sixty merged commit 20e6e9b into main Jul 16, 2026
5 checks passed
@max-sixty
max-sixty deleted the daily/review-runs-28505815799 branch July 16, 2026 16:50
@max-sixty max-sixty mentioned this pull request Jul 16, 2026
2 of 3 tasks
max-sixty added a commit that referenced this pull request Jul 16, 2026
## Summary

Version bump + CHANGELOG for 0.1.11. See
[CHANGELOG.md](https://github.com/max-sixty/tend/blob/release/CHANGELOG.md#0111)
for the full notes.

13 commits since 0.1.10:
- Adopter sandbox levers (`sandbox_path`/`sandbox_env`/`sandbox_setup`,
#768)
- Sandbox `PATH` derived from the runner's own `PATH` (#767)
- Invited upstream contributions (#770)
- `tend-mention` self-comment no-op skip (#751)
- Actionable self-review handling (#762, #775)
- `tend-outage` dedup self-heal (#744)
- Dropped-cron-tick recovery in `list-recent-runs` (#753)
- Drop self-authored attribution sign-offs (#773)
- Docs fixes (#776, #771)
- `claude_version` bump (#774)

## Test plan

- [x] `wt test` (275 passed)
- [x] `pre-commit run --all-files` (all hooks passed)
- [ ] CI green on this PR

> _This was written by Claude Code on behalf of Maximilian Roos_
max-sixty added a commit that referenced this pull request Jul 16, 2026
## Summary

- Regenerates tend's own `.github/workflows/tend-*.yaml` via `uvx
tend@latest init` against the just-released 0.1.11.
- Action pins move `0.1.10` → `0.1.11`.
- `tend-mention.yaml` picks up the bot-self-comment no-op skip (#751).

## Test plan

- [x] `uvx tend@latest init` ran clean, wrote 8 files
- [ ] CI green on this PR

> _This was written by Claude Code on behalf of Maximilian Roos_
max-sixty pushed a commit to max-sixty/worktrunk that referenced this pull request Jul 17, 2026
Automated nightly regeneration of tend's workflow files, picking up the
upstream release.

**tend version:** 0.1.10 → 0.1.11

**Notable changes** (consumer-relevant):

- Skip no-op `tend-mention` sessions triggered by the bot's own comments
— a new pre-mention guard in the generated `tend-mention.yaml`
short-circuits before the engagement heuristics (max-sixty/tend#751).
- Respond to actionable bot self-reviews instead of exiting as a
self-loop: a review the review workflow leaves on its own PR is the
bot's reviewer role, so it gets actioned rather than silently skipped
(max-sixty/tend#762).
- Sandbox: adopter levers to reach inside the Claude-family sandbox, and
derive the sandbox `PATH` from the runner's `PATH` (max-sixty/tend#768,
max-sixty/tend#767).
- `running-in-ci`: permit maintainer-invited upstream contributions, and
prohibit self-authored attribution sign-offs (max-sixty/tend#770,
max-sixty/tend#773).
- Action reliability: self-heal duplicate `tend-outage` issues from
concurrent leg failures, and recover dropped cron ticks in
list-recent-runs via a previous-run anchor (max-sixty/tend#744,
max-sixty/tend#753).

Compare: max-sixty/tend@0.1.10...0.1.11

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

Labels

review-runs Findings from review-runs skill

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tend-mention: review-runs tracking-issue comment edit self-triggers a daily no-op session (User-type PAT bot escapes the #606 skip)

2 participants