Skip to content

fix(gh): make stop hook block once per user turn - #29

Merged
FradSer merged 1 commit into
mainfrom
fix/gh-stop-hook-once
Aug 9, 2026
Merged

FradSer merged 1 commit into
mainfrom
fix/gh-stop-hook-once

Conversation

@FradSer

@FradSer FradSer commented Aug 9, 2026 •

Copy link
Copy Markdown
Owner

What

Makes the github plugin's Stop hook (closeout-stop.sh) block at most once per user turn instead of on every turn end, fixing the repeated stop-hook loop the plugin hit when the closeout state was armed.

Why

The hook previously blocked every turn-end while .git/review-pr-closeout.json existed, until Claude Code's 8-consecutive-block cap forced a stop. A model mid-closeout would get the same reminder injected repeatedly across the turn.

Changes

  • Added a pass-through guard on stop_hook_active (the documented anti-loop pattern): when the turn is already continuing from a stop-hook block, exit cleanly so the turn ends after the single reminder.
  • Removed the now-dead "blocked repeatedly" branch and its manual .git/review-pr-closeout.json deletion escape hatch.
  • Synced wording in review-pr/SKILL.md, create-pr/SKILL.md, and references/closeout.md from "every turn end is blocked (8-cap)" to "one turn-end per user turn is blocked."

Review cycle

1 comment triaged over 1 round (Code Terrier): 1 rejected — its additionalContext-not-honored claim was based on a stale autoresearch comment and is refuted by current docs. All CI green.
Full breakdown: #29 (comment)

Verification

  • Guard tests: 8/8 passed — armed (ask + auto) blocks on a fresh turn; stop_hook_active=true, subagent, no-state, corrupt-state, non-numeric-PR all pass (fail open); first-blocks/second-passes confirms one reminder per turn.
  • Live hook test: fresh-turn stdin → blocks with the reminder; continuation stdin (stop_hook_active=true) → silent exit 0.
  • python3 plugin-optimizer/scripts/validate-plugin.py github/ → PASSED.
  • Secret scan of the diff → clean.

- Pass through the stop hook when stop_hook_active is true
- Allow turn to end after a single stop hook reminder
- Update skill docs to reflect one-turn-end-per-user-turn behavior

The GitHub review-pr stop hook previously blocked every turn end attempt
while the closeout state was armed, potentially causing an infinite loop
of blocking messages. This update checks the stop_hook_active flag to
ensure that the hook blocks at most once per user turn, allowing
subsequent attempts within the same turn to proceed. Corresponding
documentation in review-pr and create-pr skills and references has been
synchronized to clarify this behavior.

Co-Authored-By: DeepSeek V4 Flash <noreply@deepseek.com>
Co-Authored-By: Git Agent <noreply@git-agent.dev>
@FradSer FradSer added the documentation Improvements or additions to documentation label Aug 9, 2026

@code-terrier code-terrier Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Terrier found 1 issue — 1 flag.

Open in Code Terrier

Comment thread github/hooks/closeout-stop.sh
@FradSer

FradSer commented Aug 9, 2026

Copy link
Copy Markdown
Owner Author

Summary of the review cycle on this PR.

Changes made

  • Rewrote the github plugin's Stop hook (closeout-stop.sh) so it blocks at most once per user turn instead of on every turn end. Added a pass-through guard on stop_hook_active (the documented anti-loop pattern) so the reminder is injected once and the turn ends cleanly; removed the now-dead "blocked repeatedly" branch and its manual-escape text.
  • Synced the wording in review-pr/SKILL.md, create-pr/SKILL.md, and references/closeout.md from "every turn end is blocked (8-cap)" to "one turn-end per user turn is blocked; the hook passes through so it does not loop."

Review findings and resolution

  • Rejected @code-terrier on closeout-stop.sh:50 — flagged that additionalContext is not honored for Stop events, citing the stale autoresearch/hooks/stop-hook.sh:185 comment. Verified against current Claude Code docs: additionalContext IS honored for Stop, sets stop_hook_active, and counts toward the 8-consecutive-continuation cap (hooks.md:2388). The pass-through is the documented anti-loop pattern; no code change needed. Replied with the doc citations, resolved the thread, and minimized the comment.

All CI checks are green and no comments remain worth adopting. This PR is ready to merge.

@FradSer
FradSer merged commit b510c97 into main Aug 9, 2026
89 checks passed
@FradSer
FradSer deleted the fix/gh-stop-hook-once branch August 9, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant