fix(server): settle aborted provider turns - #6018
Conversation
Persist matching canonical aborts as interrupted session lifecycle events so clients stop showing active work. Keep duplicate, stale, replayed, and later terminal provider events deterministic across Codex and OpenCode.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
ApprovabilityVerdict: Needs human review This bug fix adds handling for aborted provider turns in the orchestration layer. While the production changes are small and follow existing patterns, they affect core session/turn lifecycle state management. Combined with the author being new to this file, human review is recommended to validate the state transition logic. You can customize Macroscope's approvability policy. Learn more. |
|
Note 🤖 GPT-6 Astra (preview) responding on behalf of Theo This was closed as part of an automated cleanup pass. If you believe it was closed in error, reply here and we will get it reopened. Closing in favor of #8859. Both patches settle the exact active aborted turn, but the retained patch also finalizes buffered assistant text and proposed plans when abort is the last event. Review continues there. The event-ordering and projection-rebuild cases from this branch are recorded on the retained PR. |
What Changed
Canonical
turn.abortedevents now persist an interrupted lifecycle through the orchestration event stream. A matching active turn becomesinterrupted, itsactiveTurnIdis cleared, and its plan progress settles so clients stop showing active work.Aborts apply only when they identify the currently active turn. Unscoped, stale, duplicate, replayed, and post-terminal aborts are lifecycle no-ops. Later provider state, completion, or exit events remain deterministic, while approval and user-input requests keep their existing pending semantics. Coverage exercises OpenCode's canonical abort path alongside Codex's native interrupted completion and compatibility abort mapping.
The production change is 22 lines; the rest of the diff is focused adapter, ordering, idempotency, and projection-rebuild coverage.
Why
Provider runtime ingestion previously cleared only in-memory plan progress for
turn.aborted; it did not persist a terminal orchestration lifecycle transition. That could leave the durable session projection atrunningand clients showing “Working” after the provider had stopped.interruptedpreserves the distinction between an aborted turn, successful completion, and failure. The fix stays event-sourced and ingestion-only: it does not write projection tables directly, alter provider behavior, restructure status models, or add shutdown/startup reconciliation.Testing
vp test runfor the four touched server suites: 144 tests passedvp run --filter t3 typecheckvp lint --report-unused-disable-directivesvp fmt --checkgit diff --checkChecklist
Prepared with GPT-5.6 Sol using the Codex harness in T3 Code.
Note
Medium Risk
Changes core thread/session lifecycle ingestion and ordering rules for aborts; mistakes could leave threads stuck “running” or flip state incorrectly, though scope is narrow and heavily tested.
Overview
Provider runtime ingestion now treats canonical
turn.abortedlike other lifecycle events: matching aborts set session status tointerrupted, clearactiveTurnId, and settle plan progress. Aborts apply only when the event’s turn id matches the thread’s active turn, so unscoped, stale, duplicate, and post-terminal aborts are no-ops.Codex and OpenCode adapters gain tests (and implied mapping) for interrupted completions, raw
turn/aborted, failedsendTurn, and interrupt flows so ingestion receives consistent abort events.Tests add projection-pipeline rebuild parity for interrupted sessions with pending approvals/user input, plus ingestion scenarios for provider ordering, idempotency, later session/turn events, and pending requests while a waiting turn aborts.
Reviewed by Cursor Bugbot for commit 7c52a7c. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix aborted provider turns to correctly settle session state as interrupted
ProviderRuntimeIngestionnow handlesturn.abortedevents by setting session status tointerrupted, clearingactiveTurnId, marking the latest turn as interrupted, and clearing plan progress — but only when the abort matches the currently active turn.CodexAdaptermapsturn/completedwith provider statusinterruptedto a canonicalturn.completedwith stateinterrupted, and mapsturn/abortedto a canonicalturn.abortedwith the reason propagated.OpenCodeAdapteremitsturn.startedthenturn.abortedon send failure, and invokes the runtime abort endpoint when a turn is interrupted.interruptedstatus on abort.Macroscope summarized 7c52a7c.