fix: prevent session stuck at running on turn completion#1364
Open
sfncore wants to merge 1 commit intopingdotgg:mainfrom
Open
fix: prevent session stuck at running on turn completion#1364sfncore wants to merge 1 commit intopingdotgg:mainfrom
sfncore wants to merge 1 commit intopingdotgg:mainfrom
Conversation
…tched turnId The STRICT_PROVIDER_LIFECYCLE_GUARD in ProviderRuntimeIngestion silently dropped turn.completed events when the event's turnId didn't match the thread's tracked activeTurnId. This caused the session to remain permanently stuck at "running" status — the UI showed "working for X minutes" indefinitely with no way to send new messages. The fix ensures turn.completed always transitions the session to "ready" regardless of turnId mismatch. A warning log is emitted when a mismatch is detected to aid future debugging of why turnIds diverge. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
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 Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
3 tasks
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.
What changed
turn.completedevents with a mismatchedturnIdare no longer silently dropped by theSTRICT_PROVIDER_LIFECYCLE_GUARDinProviderRuntimeIngestion. A warning log is emitted instead.Why
When the runtime emits
turn.completedwith aturnIdthat doesn't match the thread's trackedactiveTurnId, the guard prevented thethread.session.setcommand from being dispatched. The session stayed at"running"permanently — the UI showed "working for X minutes" indefinitely with no way to send new messages. Switching threads and back sometimes fixed it (full state resync).Files changed
ProviderRuntimeIngestion.ts—turn.completedalways applies regardless of turnId mismatch; warning log on mismatchProviderRuntimeIngestion.test.ts— updated 2 tests to match new behaviorAll 25 existing tests pass.
Note
Medium Risk
Changes provider lifecycle guarding so
turn.completedcan clear a running session even whenturnIdmismatches, which could mask real turn-tracking bugs or end a session earlier than expected. Scope is limited to runtime ingestion and covered by updated tests plus a new warning log for observability.Overview
Prevents threads from getting stuck in a perpetual
runningstate by changingProviderRuntimeIngestionto always applyturn.completedevents even whenSTRICT_PROVIDER_LIFECYCLE_GUARDdetects aturnIdmismatch or missingturnId.When this mismatch occurs under strict guarding, the ingestion layer now emits a warning log and still dispatches the session transition to
ready/error. Tests were updated to assert the new behavior (mismatchedturn.completednow clearsactiveTurnIdand readies the session).Written by Cursor Bugbot for commit 64ae7ce. This will update automatically on new commits. Configure here.
Note
Fix session stuck in running state on turn completion when turnId mismatches
turn.completedevents when theturnIddidn't match the active turn, leaving sessions stuck in the running state.turn.completedis always accepted regardless ofturnIdmismatch or missing active turn, unconditionally transitioning the session to ready.threadId,eventTurnId,activeTurnId) whenSTRICT_PROVIDER_LIFECYCLE_GUARDis enabled and a mismatch is detected.turn.completedfrom a different turn now clears the running state; previously it had no effect.Macroscope summarized 64ae7ce.