Repository navigation
Count a Codex thread as new only once Codex reports its session - #47
Merged
aaroncoville merged 2 commits intoOct 10, 2026
Merged
Conversation
A /new that Codex did not act on was still recorded as a new thread. The worker's earlier follow-ups then looked like new work, and the mail it had just been handed belonged to no thread. The record moved as soon as the keystrokes reached the terminal. But Codex drops a /new it refuses (one typed while a turn is running, on 0.162.0) without leaving it in the input box, and the brief and nudge pasted after it then join the turn already running, in the same session. The new thread's first prompt reports its new session id through the hooks. A few seconds after the paste is submitted, the worker's registry session is compared with the one before. Only a changed id records the new thread. Otherwise the mail is recorded as handed to the thread it actually went to. No nudge is typed into the worker until that is decided.
🚫 This PR is missing its before/after evidenceEvery pull request here has to show its work. Screenshots or a short screen recording, before the change and after it.
How to fix it: edit the description, keep the A bug fix with no visible surface still needs it: show the failing behaviour, then the same steps passing. A terminal recording is fine. Genuinely nothing to show — a CI tweak, a typo, a dependency bump? A maintainer can apply the |
…low-ups behind The test of a confirmed move only checked that a follow-up to the new thread stays in it, which holds whether the record starts over or keeps the old thread's messages. Keeping them would continue a late fix round for the previous review into a thread that no longer has its context. Assert that such a fix round is new work.
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 & why
When a Codex worker is moved to a new thread, the app types
/new, then the worker's brief and its inbox nudge. Until now the thread record moved as soon as those keystrokes reached the terminal. But Codex drops a/newit refuses (one typed while a turn is running) without leaving it in the input box. The brief and nudge pasted after it then join the turn already running, in the same session. The record then described a thread that did not exist. The worker's earlier follow-ups looked like new work, and the mail it had just been handed belonged to no thread.The new thread's first prompt reports its new session id through the hooks. So the move is now recorded only once that id shows: about ten seconds after the paste is submitted, the worker's registry session is compared with the one it had before.
No other nudge is typed into the worker until that is decided. The
codex-new-threadlog line now carriesswitched.Type of change
Evidence
Before
On Codex 0.162.0, I replayed the exact keystroke plan into a pseudo-terminal while a turn was running (a 400-line output task). These are the hook payloads Codex sent:
No new session started, and nothing was left in the composer: the second prompt starts with the brief, not with
/new. Even so, the code before this change recorded a new thread. Here is the new test, run against that code:After
switched: true. Its record starts over, so a late fix round for the previous review is new work.switched: false, and the worker keeps its thread.Full suite: 1757 of 1759 pass, 2 skipped, 0 failing.
How I tested it
switchedtrue, forced it false, dropped the fallback record, recorded a confirmed move as a fallback, and never released the in-flight guard (which would swallow every later nudge to that worker). Each one turned the suite red.npm run typecheck: 0 errors.npm run build: succeeds.Credit (optional)
Discord:
X:
Checklist
npm run typecheckpasses.npm run test:focusedpasses.npm run buildsucceeds.commented-out code, or unrelated formatting churn in it.
DESIGN.md/tokens.ts— no ad-hoc colors,spacing, or fonts. (No UI.)
ATTRIBUTION.md. (No art.)