fix: replay buffered thread lifecycle events before turn filtering - #581
Open
axisrow wants to merge 1 commit into
Open
fix: replay buffered thread lifecycle events before turn filtering#581axisrow wants to merge 1 commit into
axisrow wants to merge 1 commit into
Conversation
thread/started and thread/name/updated notifications for subagent threads can arrive before the main turn ID is known and get buffered. The live notification handler already special-cases these two methods to bypass belongsToTurn() filtering, but the buffered-replay path in captureTurn() did not, so early subagent thread labels were silently dropped and job logs fell back to raw thread IDs like thr_2. Apply the same bypass when replaying buffered notifications. Closes #36
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.
Summary
thread/started/thread/name/updatednotifications unconditionally before applying turn-scopedbelongsToTurn()filtering to the rest of the buffer incaptureTurn().Why
Closes #36.
The live notification handler in
captureTurn()already special-casesthread/startedandthread/name/updatedto bypass turn-scoped filtering (since a subagent's turn ID isn't known yet when its thread first announces itself). The buffered-replay path that runs once the main turn ID becomes available did not apply the same bypass — it ran every buffered notification throughbelongsToTurn(), which drops thread-lifecycle events for threads that don't yet have a tracked turn ID.If a subagent thread announces itself early enough to be buffered rather than handled live, its label gets silently dropped, and job logs and progress output fall back to raw thread IDs like
thr_2instead of the agent's nickname (e.g.design-challenger).Fix
Apply the same
thread/started/thread/name/updatedbypass in the buffered-replay loop that the live handler already uses.Validation
node --test tests/*.test.mjs— all subagent-labeling tests pass:task logs subagent reasoning and messages with a subagent prefixtask ignores later subagent messages when choosing the final returned outputtask can finish after subagent work even if the parent turn/completed event is missingtask using the shared broker still completes when Codex spawns subagentsnpm run buildpasses with no type errors.with-subagentintests/fake-codex-fixture.mjs) already sendsthread/startedfor the subagent thread ahead of the main turn's response, exercising exactly this race.