fix(server): wait for terminal checkpoints before new messages #10297
Closedt3dotgg(GitHub profile, opens in a new tab)wants to merge 14 commits into
t3code/debt-gzuf-4-runtime-finalization fromt3code/debt-gzuf-5-completionopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/server/src/orchestration/Layers/ProviderCommandReactor.ts line 1742Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1702,3 +1729,11 @@17021729 yield* increment(orchestrationEventsProcessedTotal, {17031730 eventType: event.type,17041731 });1732+ if (1733+ event.type === "thread.turn-interrupt-requested" ||1734+ event.type === "thread.session-stop-requested"1735+ ) {1736+ const delayed = delayedTurnStarts.get(event.payload.threadId);1737+ delayedTurnStarts.delete(event.payload.threadId);1738+ if (delayed) {1739+ yield* Effect.forEach(
- apps/server/src/provider/Layers/ProviderService.ts lines 2083 to 2091OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2076,7 +2083,9 @@20762083 export const ProviderServiceLive = Layer.effect(20772084 ProviderService.ProviderService,20782085 makeProviderService(),2079-);2086+).pipe(Layer.provide(TurnCheckpointCapture.layer));2080208720812088 export function makeProviderServiceLive(options?: ProviderServiceLiveOptions) {2082- return Layer.effect(ProviderService.ProviderService, makeProviderService(options));2089+ return Layer.effect(ProviderService.ProviderService, makeProviderService(options)).pipe(2090+ Layer.provide(TurnCheckpointCapture.layer),2091+ );
- apps/server/src/checkpointing/TurnCheckpointCapture.ts lines 37 to 39OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -0,0 +19,21 @@19+interface ThreadCaptureState {20+ activeTurnId: TurnId | undefined;21+ readonly pending: Set<PendingCapture>;22+}23+24+export class TurnCheckpointCapture extends Context.Service<25+ TurnCheckpointCapture,26+ {27+ readonly observe: (event: ProviderRuntimeEvent) => Effect.Effect<void>;28+ readonly expectInterrupt: (threadId: ThreadId) => Effect.Effect<Effect.Effect<void>>;29+ readonly pendingCapture: (threadId: ThreadId) => Effect.Effect<Effect.Effect<void> | undefined>;30+ readonly awaitCapture: (threadId: ThreadId) => Effect.Effect<void>;31+ readonly complete: (event: TerminalEvent, outcome: CaptureOutcome) => Effect.Effect<void>;32+ }33+>()("t3/checkpointing/TurnCheckpointCapture") {}34+35+// Tracks known terminal events before they reach the independent runtime consumers.36+// An interrupt reserves the known active turn before adapter cancellation can return.37+export const layer = Layer.effect(38+ TurnCheckpointCapture,39+ Effect.sync(() => {
t3dotgg(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
Bugbot is paused — on-demand spend limit reached
Bugbot uses usage-based billing for this team and has hit its on-demand spend limit.
A team admin can raise the spend limit in the Cursor dashboard, or wait for the next billing cycle to continue.