fix(server): settle error session exits - #7854
Conversation
|
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: Approved at Macroscope's review found this PR approvable — Straightforward bug fix that correctly handles error session exits by setting status to 'error' instead of 'stopped' and preserving the error message. The change is self-contained with a corresponding test case validating the fix. You can add or adjust custom eligibility rules. Learn more. |
Problem
An abruptly terminated provider process can emit a typed session.exited event with exitKind error without a separate runtime.error. The ingestion path treated every session exit as a normal stop, leaving an active turn without an error state.
Fix
Treat error-classified session exits as an error lifecycle transition, clear the active turn, and preserve the provider exit reason as lastError. Graceful exits remain stopped.
Added a focused regression test covering an active turn followed by an error session exit without runtime.error.
Verification
Model: GPT-5.6 Luna
Harness: OpenCode
Note
Medium Risk
Touches provider session lifecycle projection, so a misclassified exit could leave threads in error vs stopped incorrectly. Scope is small and covered by a focused test.
Overview
Treats unexpected provider process exits as a real session error, not a graceful stop.
When
session.exitedarrives withexitKind: "error"(even without a separateruntime.error), ingestion now sets session status toerror, clears the active turn, and stores the provider exit reason aslastError. Normal exits still map tostopped.Adds a regression test for an in-flight turn followed by an error-classified session exit.
Reviewed by Cursor Bugbot for commit ccdecf1. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Set session status to 'error' on unexpected
session.exitedevents inProviderRuntimeIngestionWhen a
session.exitedevent arrives withexitKind='error', the ingestion layer now sets the thread session status to'error', clearsactiveTurnIdto null, and recordslastErrorfrom the payload reason (or a default message). Non-error exits continue to set status to'stopped'. Adds a test verifying this transition.thread.session.setcommand now useslifecycleStatusinstead of the previously computedstatus; any downstream consumers expecting'stopped'for error exits will see'error'instead.Macroscope summarized ccdecf1.