fix(server): cancel pending questions on stop #7987
ClosedExotic209093(GitHub profile, opens in a new tab)wants to merge 2 commits into
main fromrefs/pull/7987/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
- @@ -1194,3 +1262,7 @@1194126211951263 // Orchestration turn ids are not provider turn ids, so interrupt by session.11961264 yield* providerService.interruptTurn({ threadId: event.payload.threadId });1265+ // Some providers discard their callbacks without emitting a matching1266+ // resolution event. Close those requests after the interrupt succeeds.1267+ yield* Effect.forEach(pendingUserInputRequests(thread.activities), ({ requestId, turnId }) =>1268+ appendCancelledUserInputActivity({
- @@ -1194,3 +1262,13 @@1194126211951263 // Orchestration turn ids are not provider turn ids, so interrupt by session.11961264 yield* providerService.interruptTurn({ threadId: event.payload.threadId });1265+ // Some providers discard their callbacks without emitting a matching1266+ // resolution event. Close those requests after the interrupt succeeds.1267+ yield* Effect.forEach(pendingUserInputRequests(thread.activities), ({ requestId, turnId }) =>1268+ appendCancelledUserInputActivity({1269+ threadId: event.payload.threadId,1270+ requestId,1271+ turnId,1272+ createdAt: event.payload.createdAt,1273+ }),1274+ );
- @@ -1194,3 +1267,10 @@1194126711951268 // Orchestration turn ids are not provider turn ids, so interrupt by session.11961269 yield* providerService.interruptTurn({ threadId: event.payload.threadId });1270+ // Some providers discard their callbacks without emitting a matching1271+ // resolution event. Close those requests once the interrupt succeeds,1272+ // deriving from a fresh read: the provider can append real resolutions1273+ // while handling the interrupt. Cancellations get server-side timestamps1274+ // so they order after the request activity even when the interrupt1275+ // command predates it.1276+ const postInterruptThread = yield* resolveThread(event.payload.threadId);@@ -275,3 +281,8 @@275281 return `Stale pending ${requestKind} request: ${requestId}. Provider callback state does not survive app restarts or recovered sessions. Restart the turn to continue.`;276282 }277283284+function pendingUserInputRequests(285+ activities: OrchestrationThread["activities"],286+): ReadonlyArray<{ readonly requestId: string; readonly turnId: TurnId | null }> {287+ const openRequests = new Map<string, TurnId | null>();288+ const ordered = [...activities].toSorted(
juliusmarminge 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:
7f4a0cd4-2f2d-4971-8ba1-fada9a9895d5You 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