codex: preserve buffered subagent thread labels#36
codex: preserve buffered subagent thread labels#36VOIDXAI wants to merge 2 commits intoopenai:mainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c8ae0c4878
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
plugins/codex/scripts/lib/codex.mjs
Outdated
| } | ||
| for (const message of state.bufferedNotifications) { | ||
| if (belongsToTurn(state, message)) { | ||
| if (isThreadLifecycleNotification(message) || belongsToTurn(state, message)) { |
There was a problem hiding this comment.
Scope buffered lifecycle replay to active turn threads
Replaying every buffered thread/started and thread/name/updated notification unconditionally can pull unrelated threads into this capture when delayed notifications from another turn are present in the buffer (for example, while review/start or turn/start is still awaiting its response). Once registerThread adds that thread, later buffered item/* notifications from it pass belongsToTurn because trackedTurnId is still null, so this turn can incorrectly absorb foreign file changes, command executions, or reasoning/log output.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Addressed in 09b2105. Instead of replaying unknown lifecycle notifications immediately, the turn capture now defers thread/started / thread/name/updated until the current turn has explicitly registered that thread. That keeps the early subagent label available once the collaboration item arrives, but foreign buffered threads stay out of the capture. I also added tests/codex-buffered-subagent.test.mjs, which buffers both a real subagent lifecycle event and an unrelated off-turn thread message to lock down this edge case.
Summary
thread/started/thread/name/updatedevents from being droppedWhy
Closes #31.
If a subagent thread is announced before the main turn ID is known, the buffered lifecycle event can be discarded during replay. That leaves the runtime without the label and logs fall back to raw thread IDs like
thr_2.Validation
design-challengerinstead of falling back tothr_2