Commit 78ec4fa
fix(codex): prevent false turn idle timeouts under event-loop pressure (#86948)
The completion-idle timer (60 s) fires based on when notifications are
*processed* inside the chained notification queue, not when they are
*received* from the app-server binary over stdio. Since ea16a5e
added a `setImmediate` yield between each queued dispatch, every
notification is delayed by at least one event-loop tick. Under heavy
load (tool-call-intensive turns) the ticks accumulate, and the
`turn/completed` notification can arrive from the binary but sit in the
queue for longer than 60 s — at which point the idle timer fires and
aborts the turn.
Fix:
1. Touch `turnCompletionLastActivityAt` and `turnAttemptLastProgressAt`
at *enqueue* time (when readline delivers the line) so the idle timer
sees live binary I/O even when the queue is backed up.
2. Guard all three idle-timeout handlers (`fireTurnCompletionIdleTimeout`,
`fireTurnAttemptIdleTimeout`, `fireTurnTerminalIdleTimeout`) with the
existing `terminalTurnNotificationQueued` flag so they never fire when
`turn/completed` has already been received but not yet processed.
Closes #86948
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 7d6b7f4 commit 78ec4fa
1 file changed
Lines changed: 19 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1979 | 1979 | | |
1980 | 1980 | | |
1981 | 1981 | | |
1982 | | - | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
| 1987 | + | |
1983 | 1988 | | |
1984 | 1989 | | |
1985 | 1990 | | |
| |||
2014 | 2019 | | |
2015 | 2020 | | |
2016 | 2021 | | |
| 2022 | + | |
2017 | 2023 | | |
2018 | 2024 | | |
2019 | 2025 | | |
| |||
2053 | 2059 | | |
2054 | 2060 | | |
2055 | 2061 | | |
| 2062 | + | |
2056 | 2063 | | |
2057 | 2064 | | |
2058 | 2065 | | |
| |||
2581 | 2588 | | |
2582 | 2589 | | |
2583 | 2590 | | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
2584 | 2602 | | |
2585 | 2603 | | |
2586 | 2604 | | |
| |||
0 commit comments