Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugins/codex/scripts/stop-review-gate-hook.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ function main() {
return;
}

if (input.stop_hook_active) {
logNote(runningTaskNote);
return;
}

const setupNote = buildSetupNote(cwd);
if (setupNote) {
logNote(setupNote);
Expand Down
27 changes: 27 additions & 0 deletions tests/runtime.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -1979,6 +1979,33 @@ test("stop hook runs a stop-time review task and blocks on findings when the rev
assert.match(status.stdout, /Codex Stop Gate Review/);
});

test("stop hook does not rerun the review when handling a blocked stop retry", () => {
const repo = makeTempDir();
const binDir = makeTempDir();
installFakeCodex(binDir);
initGitRepo(repo);

const setup = run("node", [SCRIPT, "setup", "--enable-review-gate", "--json"], {
cwd: repo,
env: buildEnv(binDir)
});
assert.equal(setup.status, 0, setup.stderr);

const retry = run("node", [STOP_HOOK], {
cwd: repo,
env: buildEnv(binDir),
input: JSON.stringify({
cwd: repo,
session_id: "sess-stop-review-retry",
stop_hook_active: true,
last_assistant_message: "This response was already reviewed."
})
});

assert.equal(retry.status, 0, retry.stderr);
assert.equal(retry.stdout.trim(), "");
});

test("stop hook logs running tasks to stderr without blocking when the review gate is disabled", () => {
const repo = makeTempDir();
initGitRepo(repo);
Expand Down