Skip to content

fix: respond to actionable bot self-reviews instead of self-loop-exiting - #762

Merged
max-sixty merged 4 commits into
mainfrom
fix/self-review-loop-guard-29055429013
Jul 12, 2026
Merged

max-sixty merged 4 commits into
mainfrom
fix/self-review-loop-guard-29055429013

Conversation

@tend-agent

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

Copy link
Copy Markdown
Collaborator

Closes #761.

Problem

When tend-review and the PR author are the same bot account (tend-on-tend, or any consumer using one bot for both authoring and reviewing), an actionable self-review is silently swallowed. tend-mention triggers correctly and Claude runs to completion, but the run reads a CHANGES_REQUESTED / COMMENTED-with-findings review on the bot's own PR, treats it as the bot talking to itself, and exits without acting. The finding only gets actioned when a human asks by hand.

The verify gate is already correct — it fires should_run=true for an actionable self-review; #749 only skips empty-body APPROVED ones. The silent exit comes from two prompt-layer guards with no reviewer/author carve-out:

  • The system-prompt self-loop guard was absolute: "before responding to a comment or review, confirm the triggering actor isn't the bot itself."
  • The non-mention pull_request_review prompt branch said only "respond appropriately … if the review approves or is between humans, exit silently" — it never named the bot-authored-review case, so it read as "between humans / self."

running-in-ci's Self-conversation Guard already documents the exception ("only respond if there is a distinct role boundary, e.g. you are the reviewer on your own PR"), but neither of the two surfaces above carried it, and the system prompt wins.

Fix — both surfaces #761 names

  1. shared/system-prompt.md — the self-loop guard now carves out the role boundary: an actionable review the bot's review workflow posted on the bot's own PR (CHANGES_REQUESTED, or COMMENTED with findings/questions) is reviewer-to-author feedback, not a self-loop — address it. A bot approval or an ask-free bot comment still exits silently.
  2. generator/src/tend/templates/mention.yaml.j2 — the non-mention review branch now positively instructs that a review your own review workflow posted on your own PR is your reviewer role speaking, so action it; exit silently only for a plain approval or a review with no actionable content.

The system prompt is composed at runtime by all three harness actions, so no workflow regeneration is needed for surface 1; surface 2 regenerates the mention regtest snapshots (updated here). Reaches adopters at the next release. All 256 generator tests pass.

Relationship to other issues/PRs

Loop consideration

If addressing the review pushes a commit, synchronize re-runs tend-review, which posts a fresh review — the same re-trigger loop that already exists for human-authored reviews, bounded by review eventually approving (terminal, gate-skipped), the mention dedup guard, and the findings actually getting resolved. Triggering here is the intended behavior.

Requested by @max-sixty in max-sixty/worktrunk#3394: "let's fix that … We need to trigger in this case."

The system-prompt self-loop guard was absolute ("confirm the triggering
actor isn't the bot itself"), so when tend-review posts a
CHANGES_REQUESTED / COMMENTED-with-findings review on the bot's own PR,
the tend-mention handle session read it as the bot talking to itself and
exited silently — overriding the handle prompt's own "if the review
requests changes or asks questions, respond appropriately."

The verify gate already lets these through (#749 only skips empty-body
APPROVED self-reviews), and running-in-ci's Self-conversation Guard
already carves out the reviewer/author role boundary. This aligns the
terse system-prompt guard with that carve-out so an actionable bot
self-review gets addressed instead of swallowed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Second half of the actionable-self-review fix. The non-mention
pull_request_review prompt branch said only 'respond appropriately',
leaving the bot-authored-review-on-own-PR case to be (mis)read as a
self-loop. Add a positive instruction that a review your own review
workflow posted on your own PR is your reviewer role speaking — action
it — and exit silently only for a plain approval or a review with no
actionable content.

Together with the system-prompt guard carve-out, this fully addresses
tend#761 (both surfaces it names).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tend-agent tend-agent changed the title prompt: respond to actionable bot self-reviews instead of self-loop-exiting fix: respond to actionable bot self-reviews instead of self-loop-exiting Jul 9, 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.

The self-review carve-out reads well and I verified the layering: the verify gate already lets an actionable bot self-review through (it skips only approved + empty-body), and the in-process render preserves the em-dash — the ? in the regenerated snapshots is the usual pytest-regtest non-ASCII normalization, consistent with the em-dashes already in that file, so no functional concern there.

One thing the rewrite dropped, though: the review branch lost its bystander off-ramp. The old text was "If the review approves or is between humans, exit silently"; the new text is "Exit silently only for a plain approval or a review with no actionable content." The only forecloses the between-participants case — a human requesting changes on another human's PR where the bot previously participated (so the verify gate fires should_run=true) now falls under "requests changes → respond appropriately (make the change and push)", pulling the bot into a review it's a bystander to.

The sibling comment-fallback branch right below still keeps its off-ramp ("If the conversation is between other participants, exit silently"), so the two fallbacks are now asymmetric — which reads as an unintended side effect of the rewrite rather than an intended scope change. Suggestion inline restores the bystander exit while keeping the self-review carve-out.

Note: applying the suggestion changes the source template only — the 3 test_workflow_*_regtest[mention] snapshots need regenerating (uv run pytest tests/ -k mention --regtest-reset) in the same commit or the regtests fail.

The self-review carve-out rewrite dropped the between-participants
off-ramp the old text carried ('or is between humans, exit silently').
The 'only for a plain approval or a review with no actionable content'
foreclosed the bystander case, so a human-to-human change request on a
PR the bot merely participated in would be actioned — asymmetric with
the comment-fallback branch, which still exits on between-other-
participants reviews. Restore the exit while keeping the self-review
carve-out.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@max-sixty

Copy link
Copy Markdown
Owner

but then the trigger hasn't changed; only the guidance?

I'm less of a fan of the guidance; it seems overly verbose

Same behavior, fewer words. @max-sixty found the added guidance overly
verbose; the trigger/gate is unchanged (this was always a prompt-layer
fix), so trim both surfaces to the minimum that still names the
reviewer-on-own-PR role boundary and keeps the bystander off-ramp.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tend-agent

Copy link
Copy Markdown
Collaborator Author

Right — the trigger and the verify gate are unchanged. The gate already fired should_run=true for these (#749 only skips empty-body APPROVED self-reviews); the bug was purely at the prompt/guidance layer, so guidance is all that moved.

Trimmed both surfaces in 36f7684 — same behavior, fewer words:

  • system-prompt guard: 8 lines → 6, folded the carve-out into the guard sentence itself.
  • mention review branch: dropped the parenthetical and the "your reviewer role speaking" restatement, kept the "including when you authored the review" clause and the bystander off-ramp.

256 tests pass, mention regtest snapshots regenerated.

@max-sixty
max-sixty merged commit 8c50fc5 into main Jul 12, 2026
5 checks passed
@max-sixty
max-sixty deleted the fix/self-review-loop-guard-29055429013 branch July 12, 2026 15:19
tend-agent added a commit that referenced this pull request Jul 12, 2026
Resolve the setup-sandbox.sh PATH conflict by combining both levers:
the adopter's explicit sandbox_path (TEND_SANDBOX_PATH) is prepended so
it wins, then the runner-PATH auto-derivation pulls in the /etc/skel-seeded
toolchains. Adopter dirs dedup against the auto-derived rewrites.

Also regenerate the stale test_sandbox_levers snapshot, which was left
mismatched against the mention template on main by #762.
max-sixty added a commit that referenced this pull request Jul 16, 2026
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 <noreply@anthropic.com>
@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 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 <254187624+worktrunk-bot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tend-mention: bot-authored review with actionable findings on bot's own PR is silently swallowed by self-loop guards

2 participants