mirror of
https://github.com/openai/codex.git
synced 2026-12-04 00:51:02 +00:00
## Why Interrupting a turn or terminating a Code Mode cell can drop a pending dynamic tool handler before it publishes its completion. Cancellation needs to settle the call in live events and persisted history without allowing a late response into model context. ## What changed - Let dynamic tool handlers observe cancellation and publish their terminal item before dispatch finishes. Calls cancelled while awaiting a response complete with a failed item and a cancellation error. - Keep readiness, dispatch admission, registry lock waits, hooks, and output processing cancellable so cancellation can finish even when a hook is blocked. - Report an aborted tool lifecycle outcome when cancellation interrupts dispatch, including before handler execution. ## Testing Add regression tests for turn interruption with pending calls or blocked hooks, cell termination with persisted failure and late-response exclusion, cancellation before dispatch admission, and exactly one completion when a response races cancellation. GitOrigin-RevId: 0112fc74c8652c91503ed5bbfb334ae2e26930ef