[#180]: fix(discover): recognise token_budget_abort and inference_stream_cancelled as turn-terminating events#184
Merged
Merged
Conversation
…elled as turn-terminating events Codex v0.142.0 introduced token_budget_abort; Codex v0.143.0 (PRs #29918, #30144) now reliably preserves both token_budget_abort and inference_stream_cancelled on disk during shutdown. The discover.rs scanner's event_msg match handled task_complete and turn_aborted as turn-terminating signals, but left these two events to fall through to the catch-all arm. Sessions ending via budget exhaustion or cancelled inference were therefore shown as is_ongoing=true in the session list until the 60-second mtime fallback elapsed. Add a combined match arm for both events that sets is_ongoing=false and captures end_time from the event timestamp, consistent with the existing turn_aborted handler. Adds two regression tests in the discover module. Fixes #180
…vents Codex v0.143.0 (PRs #29918 and #30144) now preserves trailing realtime transcript text and terminal rollout events during shutdown, and writes session_end reliably via an atexit handler even after crashes. Add a clarifying comment in turn.rs explaining that unknown event types at the tail of a v0.143.0 session carry no turn-building semantics and are safely handled by the existing catch-all. Add two regression tests in session.rs: - v0143_trailing_transcript_and_reliable_session_end_parse_correctly: a normal session with a trailing unknown event (realtime_transcript_text) between task_complete and session_end parses correctly with is_ongoing=false and final_answer populated. - v0143_session_end_without_task_complete_marks_turn_aborted: a crash scenario where session_end is written by the atexit handler but task_complete was never emitted; the existing abrupt-cutoff workaround fires and sets TurnStatus::Aborted, is_ongoing=false. Fixes #180
Codex v0.143.0 (PRs #29918, #30144) preserves trailing transcript text and terminal rollout events during shutdown instead of dropping them. Some of these events end in `_end` but carry no call_id and aren't real tool calls. finalize_unknown_end() used unwrap_or_else to fabricate a pending call for any unmatched _end event, so these non-tool-call events were turned into phantom ToolCalls in the turn's tool list. Guard against this by returning early when call_id is empty and no pending call matches, so terminal rollout events are discarded instead of corrupting the turn. Fixes #180
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.
Problem
Codex v0.142.0 introduced
token_budget_abort(fired when the rollout token budget is exhausted) andinference_stream_cancelled(fired when inference is cancelled mid-turn). Codex v0.143.0 (PRs #29918 and #30144) now reliably flushes both events to disk during shutdown — previously they could be lost.The
scan_session_filefunction indiscover.rsclassifies a session as completed by recognising turn-terminating events (task_complete,turn_aborted). However,token_budget_abortandinference_stream_cancelledfell through to the catch-all_ => {}arm and were silently ignored. As a result, sessions that terminated via budget exhaustion or cancelled inference were incorrectly shown asis_ongoing = truein the session list until the 60-second mtime fallback elapsed.Fix
Added a combined match arm in the
event_msgbranch ofscan_session_file:This mirrors the existing
turn_abortedhandler and correctly marks the session as not ongoing, capturingend_timefrom the event timestamp.Tests
Two regression tests added to
src-tauri/src/parser/discover.rs:v0143_token_budget_abort_marks_session_not_ongoing— verifies a session file containingtoken_budget_abort(notask_complete) is discovered withis_ongoing = falseand correctend_time.v0143_inference_stream_cancelled_marks_session_not_ongoing— same forinference_stream_cancelled.All 323 Rust lib tests pass. Clippy
-D warningsclean.Fixes #180