Repository navigation
Codex mode hook: an on that sage cannot see start a turn does not count (T896) - #460
Merged
Merged
Conversation
…e turn of the saved on (T896) F-T896-1: after an off from another thread, an on that joined the same running turn could turn merges on again when the hook could not read Codex's record (no record, or a partial last line). The hook now treats an unreadable record, or a turn that already holds the saved on, as joined: the on does not count, no turn is saved, and the chief's note says why and asks for a new message while Codex is idle. The test sessions now start a new turn for each prompt and keep Codex's record, as a message sent while Codex is idle does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…be read (T896) Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 9, 2026
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.
What this is
The last narrow exception to the owner's rule (option A: an on phrase counts only from the owner's message that starts a turn). Finding F-T896-1 (was F-T823-2), low, security class.
The problem
After an off phrase from another thread (a fork, a subagent's thread, a side conversation), an on phrase that joined the main thread's running turn could still turn merges on again when the Codex mode hook could not read Codex's record at that moment: no record (no
transcript_path), or a last line that Codex still writes (about 150 ms of re-reads). The hook then accepted the on and saved the same turn that the gate counts.The change
packages/sage-codex/hooks/sage-codex-hook.mjs:joinsnow gives the reason why an on cannot count. An unreadable record, or a turn that already holds the saved on (state.onTurnequalsturn_id), joins: the on switches nothing and saves no turn. The chief's note says why, and tells the user to send the on phrase alone as a new message while Codex is idle. The comments match.docs/guide/codex.md: two limit lines. An on phrase queued with Tab in the terminal UI counts when it starts the next turn, and it still fires after an off phrase sent before that turn starts; to cancel it, remove it from the queue or queue the off phrase after it. An on phrase counts for nothing when the hook cannot read Codex's record at that moment.changes/T896.md: the change log entry.Tests
scripts/codex-mode-hook.test.mjs: two new tests. (1) No record, and a record with a partial last line after an off from a fork: the on switches nothing, autopilot stays off (or stays on from the earlier on), and the saved turn does not change. (2) A second on in the turn that holds the saved on, before Codex records the first: it switches nothing and saves nothing new. Both fail on the base 5bc9422 and pass here.codex-mode-hook.test.mjsand the Codex sessions inbranch-protection.test.mjsnow start a new turn for each prompt (and the latter keep Codex's record), as a message sent while Codex is idle does. Before, every prompt of a session shared one turn id, which the new saved-turn rule correctly refuses.The gate (
gate-hook.mjs) does not change.🤖 Generated with Claude Code