Repository navigation
fix(agent): finish interrupted turns promptly - #285
Merged
Merged
Conversation
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.
Stopping a running Codex turn could leave the Agent pane stuck because Red discarded the active turn ID when it sent
turn/interrupt, then ignored the matching terminal notification. The elapsed status also kept counting from the beginning of the turn, which made cancellation look slower than it was.This change keeps the active turn authoritative until
turn/completed, tracks and coalesces a pending interrupt separately, and reports the cancellation request to the pane as soon as it is dispatched. It also handles cancellation beforeturn/startreturns and keeps both cancellation/completion event orderings from stranding the busy state.The
Stopping…status now restarts its elapsed timer so it measures cancellation latency rather than total turn duration.How to Test
Ctrl-c. ExpectStopping…to appear immediately with a fresh elapsed timer, then clear when Codex confirms the interruption.Ctrl-crepeatedly, or cancel while a turn is starting or completing. Expect one interrupt request for the active turn and an idle pane after the terminal event, regardless of event ordering.Focused automated coverage:
cargo test codex::testscargo test bundled_agent_rotates_when_completion_wins_the_cancellation_racecargo test bundled_agent_rotates_when_cancellation_wins_the_completion_racecargo clippy --all-targets --all-features -- -D warnings