fix(server): settle aborted provider turns #6018
main fromrefs/pull/6018/head·opened View on GitHubWhat Changed#
Canonical turn.aborted events now persist an interrupted lifecycle through the orchestration event stream. A matching active turn becomes interrupted, its activeTurnId is 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 at running and clients showing “Working” after the provider had stopped.
interrupted preserves 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 typecheck- Targeted
vp lint --report-unused-disable-directives - Targeted
vp fmt --check git diff --check
Checklist#
- This PR is small and focused
- I explained what changed and why
- UI screenshots are not applicable
- Animation or interaction video is not applicable
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.aborted like other lifecycle events: matching aborts set session status to interrupted, clear activeTurnId, 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, failed sendTurn, 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](https://cursor.com/bugbot) for commit 7c52a7c4a7cf3aeff659b1b1748729868e6d46fc. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).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.- Stale, duplicate, unscoped, and post-terminal aborts are ignored and no longer mutate lifecycle state or plan progress.
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.- Behavioral Change: previously aborted turns did not settle session state; sessions will now transition to
interruptedstatus on abort.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
Approvability#
Verdict: 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](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).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.
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Important
Review skipped#
Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID:
321199a2-30b2-4012-8c68-85f5a1eb5b25You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.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.
❤️ Share