Add optional CODEX_REVIEW_GATE_MAX_ROUNDS cap to the stop review gate#396
Open
dxcmb wants to merge 2 commits into
Open
Add optional CODEX_REVIEW_GATE_MAX_ROUNDS cap to the stop review gate#396dxcmb wants to merge 2 commits into
dxcmb wants to merge 2 commits into
Conversation
The stop-time review gate has no built-in bound: it keeps blocking the stop while Codex returns BLOCK, which can create a long-running Claude/Codex loop (as the README itself warns). This adds an opt-in cap via the CODEX_REVIEW_GATE_MAX_ROUNDS env var. When set to a positive integer, the gate allows the stop after that many consecutive blocked rounds in a session. Unset/0 keeps the previous unbounded behavior. Rounds are counted per session via stop_hook_active and persisted in the existing per-workspace state config.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The stop-time review gate has no built-in bound.
stop-review-gate-hook.mjskeeps emitting{"decision":"block"}as long as the Codex review returnsBLOCK:, and it does not consult thestop_hook_activeflag. As the README itself warns, this can create a long-running Claude/Codex loop that drains usage limits. The only controls today are watching the session and hitting Esc, or toggling the gate off entirely.Change
Add an opt-in cap via the
CODEX_REVIEW_GATE_MAX_ROUNDSenvironment variable:0→ unbounded (current behavior, fully backward compatible).N→ afterNconsecutive blocked rounds in a session, the gate allows the stop instead of blocking again, with a note pointing back to/codex:review --waitand the env var.Rounds are counted per session:
stop_hook_active === false(a fresh user turn) starts the count at 0.session_idin the existing per-workspace state config (setConfig/getConfig), so no new storage mechanism is introduced.Why an env var
It keeps the default untouched (no behavior change for anyone not setting it), needs no new setup flag or migration, and is trivial to set per-project or per-session for users who run the gate routinely and want a guaranteed ceiling.
Files
plugins/codex/scripts/stop-review-gate-hook.mjs— round counting + cap; importssetConfig.README.md— documents the env var under the review-gate section.Testing
Verified manually that with the gate enabled and
CODEX_REVIEW_GATE_MAX_ROUNDS=N, the hook blocks forNrounds and then allows the stop, and that leaving the var unset preserves the existing unbounded behavior. Happy to add a unit test undertests/if you'd like — pointers to the preferred harness welcome.🤖 Generated with Claude Code