[orchestrator-v2] fix(orchestrator): Harden Grok v2 settlement, background task lifecycle, steer visibility, and images #3578
Mergedmwolson(GitHub profile, opens in a new tab)merged 1 commit into
t3code/codex-turn-mapping fromrefs/pull/3578/headmerged by juliusmarminge View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 4164OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2061,0 +2143,21 @@2143+ const trySettleRootTurnWhenIdle = Effect.fnUntraced(function* (context: ActiveAcpTurn) {2144+ const pending = yield* Ref.get(pendingRuntimeRequests);2145+ const hasPendingRuntimeRequest = [...pending.values()].some(2146+ (request) =>2147+ request.runtimeRequest.providerTurnId === context.providerTurnId &&2148+ request.runtimeRequest.status === "pending",2149+ );2150+ const hasRunningTool = [...context.tools.values()].some((tool) => {2151+ const status = toolStatus(tool.status);2152+ return status === "pending" || status === "running";2153+ });2154+ if (2155+ !acpRootTurnIsIdle({2156+ finalized: context.finalized,2157+ interrupted: context.interrupted,2158+ assistantStreamOpen: context.assistant.current !== null,2159+ reasoningStreamOpen: context.reasoning.current !== null,2160+ hasRunningTool,2161+ hasPendingRuntimeRequest,2162+ hasActivePlan: context.plan !== null,2163+ hasOutput: context.assistant.nextSegment > 0,apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts lines 139 to 141OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -114,0 +121,21 @@121+ readonly hasPendingRuntimeRequest: boolean;122+ readonly hasActivePlan: boolean;123+ readonly hasOutput: boolean;124+}125+126+/** Wait for follow-on tool calls after a brief assistant preamble. */127+export const acpRootTurnSettleDebounceMs = 2_000;128+129+/** Fail silent post-prompt hangs when no root session traffic arrives. */130+export const acpRootTurnPromptLivenessMs = 30_000;131+132+/** Let trailing root session chunks land before terminalizing a settled turn. */133+export const acpRootTurnCompletionDrainMs = 100;134+135+/** True when root-session streaming is quiescent and the turn can settle locally. */136+export function acpRootTurnIsIdle(snapshot: AcpRootTurnIdleSnapshot): boolean {137+ if (snapshot.finalized || snapshot.interrupted) return false;138+ if (snapshot.assistantStreamOpen || snapshot.reasoningStreamOpen) return false;139+ if (snapshot.hasRunningTool || snapshot.hasPendingRuntimeRequest) return false;140+ if (snapshot.hasActivePlan) return false;141+ return snapshot.hasOutput;apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 173OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -114,0 +119,21 @@119+ readonly reasoningStreamOpen: boolean;120+ readonly hasRunningTool: boolean;121+ readonly hasPendingRuntimeRequest: boolean;122+ readonly hasActivePlan: boolean;123+ readonly hasOutput: boolean;124+}125+126+/** Wait for follow-on tool calls after a brief assistant preamble. */127+export const acpRootTurnSettleDebounceMs = 2_000;128+129+/** Fail silent post-prompt hangs when no root session traffic arrives. */130+export const acpRootTurnPromptLivenessMs = 30_000;131+132+/** Let trailing root session chunks land before terminalizing a settled turn. */133+export const acpRootTurnCompletionDrainMs = 100;134+135+/** True when root-session streaming is quiescent and the turn can settle locally. */136+export function acpRootTurnIsIdle(snapshot: AcpRootTurnIdleSnapshot): boolean {137+ if (snapshot.finalized || snapshot.interrupted) return false;138+ if (snapshot.assistantStreamOpen || snapshot.reasoningStreamOpen) return false;139+ if (snapshot.hasRunningTool || snapshot.hasPendingRuntimeRequest) return false;apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 159OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -112,3 +112,21 @@112112 ) => Effect.Effect<ProviderUserInputAnswers | null, EffectAcpErrors.AcpError>;113113 }114114115+export interface AcpRootTurnIdleSnapshot {116+ readonly finalized: boolean;117+ readonly interrupted: boolean;118+ readonly assistantStreamOpen: boolean;119+ readonly reasoningStreamOpen: boolean;120+ readonly hasRunningTool: boolean;121+ readonly hasPendingRuntimeRequest: boolean;122+ readonly hasActivePlan: boolean;123+ readonly hasOutput: boolean;124+}125+126+/** Wait for follow-on tool calls after a brief assistant preamble. */127+export const acpRootTurnSettleDebounceMs = 2_000;128+129+/** Fail silent post-prompt hangs when no root session traffic arrives. */130+export const acpRootTurnPromptLivenessMs = 30_000;131+132+/** Let trailing root session chunks land before terminalizing a settled turn. */
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 1530OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1460,3 +1527,4 @@14601527 context.pendingSubagentNotifications.set(notification.sessionId, buffered);14611528 return;14621529 }1530+ context.hasRootActivity = true;apps/web/src/components/ChatView.tsx line 1159OutdatedResolvedby mwolson(GitHub profile, opens in a new tab)@@ -1063,5 +1064,5 @@10631064 routeKind === "server" ? routeThreadRef : null,10641065 );10651066 const committedServerMessageIds = useMemo(1066- () => new Set(serverProjection?.messages.map((message) => message.id) ?? []),1067- [serverProjection],1067+ () => deriveCommittedServerUserMessageIds(serverVisibleTurnItems),1068+ [serverVisibleTurnItems],apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 2162OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2061 +2142,21 @@206121422143+ const trySettleRootTurnWhenIdle = Effect.fnUntraced(function* (context: ActiveAcpTurn) {2144+ const pending = yield* Ref.get(pendingRuntimeRequests);2145+ const hasPendingRuntimeRequest = [...pending.values()].some(2146+ (request) =>2147+ request.runtimeRequest.providerTurnId === context.providerTurnId &&2148+ request.runtimeRequest.status === "pending",2149+ );2150+ const hasRunningTool = [...context.tools.values()].some((tool) => {2151+ const status = toolStatus(tool.status);2152+ return status === "pending" || status === "running";2153+ });2154+ if (2155+ !acpRootTurnIsIdle({2156+ finalized: context.finalized,2157+ interrupted: context.interrupted,2158+ assistantStreamOpen: context.assistant.current !== null,2159+ reasoningStreamOpen: context.reasoning.current !== null,2160+ hasRunningTool,2161+ hasPendingRuntimeRequest,2162+ hasActivePlan: context.plan !== null,
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 4171OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2061,0 +2150,21 @@2150+ request.runtimeRequest.status === "pending",2151+ );2152+ const hasRunningTool = [...context.tools.values()].some((tool) => {2153+ const status = toolStatus(tool.status);2154+ return status === "pending" || status === "running";2155+ });2156+ if (2157+ !acpRootTurnIsIdle({2158+ finalized: context.finalized,2159+ interrupted: context.interrupted,2160+ assistantStreamOpen: context.assistant.current !== null,2161+ reasoningStreamOpen: context.reasoning.current !== null,2162+ hasRunningTool,2163+ hasPendingRuntimeRequest,2164+ hasActivePlan: context.plan !== null,2165+ hasOutput: context.assistant.nextSegment > 0,2166+ })2167+ ) {2168+ return;2169+ }2170+ yield* finalizeTurn(context, "completed", undefined, { drainTrailingChunks: true });apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 4164OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2061,0 +2145,21 @@2145+ const trySettleRootTurnWhenIdle = Effect.fnUntraced(function* (context: ActiveAcpTurn) {2146+ const pending = yield* Ref.get(pendingRuntimeRequests);2147+ const hasPendingRuntimeRequest = [...pending.values()].some(2148+ (request) =>2149+ request.runtimeRequest.providerTurnId === context.providerTurnId &&2150+ request.runtimeRequest.status === "pending",2151+ );2152+ const hasRunningTool = [...context.tools.values()].some((tool) => {2153+ const status = toolStatus(tool.status);2154+ return status === "pending" || status === "running";2155+ });2156+ if (2157+ !acpRootTurnIsIdle({2158+ finalized: context.finalized,2159+ interrupted: context.interrupted,2160+ assistantStreamOpen: context.assistant.current !== null,2161+ reasoningStreamOpen: context.reasoning.current !== null,2162+ hasRunningTool,2163+ hasPendingRuntimeRequest,2164+ hasActivePlan: context.plan !== null,2165+ hasOutput: context.assistant.nextSegment > 0,
- apps/server/src/provider/acp/XAiAcpExtension.ts line 1148OutdatedResolvedby mwolson(GitHub profile, opens in a new tab)@@ -466,11 +447,9 @@466447 });467448 };468449469-function promptIdFromResponse(response: EffectAcpSchema.PromptResponse): string | undefined {470- const meta = response._meta;471- if (meta === null || typeof meta !== "object") {472- return undefined;473- }474- const promptId = meta.promptId ?? meta.requestId;475- return typeof promptId === "string" && promptId.length > 0 ? promptId : undefined;476-}450+/**451+ * Grok-specific ACP runtime wrapper. Races `session/prompt` against root-session452+ * `_x.ai/session/prompt_complete` notifications (sessionId-matched). Subagent453+ * completions on foreign session ids are ignored by the pending-entry gate.454+ */455+export const makeXAiPromptCompletionRuntime = Effect.fn("makeXAiPromptCompletionRuntime")(
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 4171OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2061,0 +2149,21 @@2149+ request.runtimeRequest.status === "pending",2150+ );2151+ const hasRunningTool = [...context.tools.values()].some((tool) => {2152+ const status = toolStatus(tool.status);2153+ return status === "pending" || status === "running";2154+ });2155+ if (2156+ !acpRootTurnIsIdle({2157+ finalized: context.finalized,2158+ interrupted: context.interrupted,2159+ assistantStreamOpen: context.assistant.current !== null,2160+ reasoningStreamOpen: context.reasoning.current !== null,2161+ hasRunningTool,2162+ hasPendingRuntimeRequest,2163+ hasActivePlan: context.plan !== null,2164+ hasOutput: context.assistant.nextSegment > 0,2165+ })2166+ ) {2167+ return;2168+ }2169+ yield* finalizeTurn(context, "completed", undefined, { drainTrailingChunks: true });apps/server/src/orchestration-v2/Adapters/GrokAdapterV2.ts line 163OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -132,3 +133,5 @@132133 const flavor: AcpAdapterV2Flavor = {133134 driver: GROK_PROVIDER,134135 capabilities: GrokProviderCapabilitiesV2,136+ settleRootTurnWhenIdle: true,137+ interruptPromptOnCancel: false,
- apps/server/src/provider/acp/XAiAcpExtension.ts lines 1236 to 1240OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -476,0 +513,21 @@513+ Deferred.await(fallback.deferred),514+ ).pipe(515+ Effect.tap((response) =>516+ rememberCompletedXAiPromptId(completedXAiPromptIdsRef, response, fallback.promptId),517+ ),518+ Effect.ensuring(519+ Effect.gen(function* () {520+ yield* Fiber.interrupt(promptRpcFiber).pipe(Effect.ignore);521+ yield* unregisterXAiPromptCompletionFallback(522+ pendingXAiPromptCompletionsRef,523+ fallback.deferred,524+ );525+ }),526+ ),527+ );528+ }),529+ cancel: Effect.gen(function* () {530+ const started = yield* runtime.start();531+ yield* abortPendingPromptCompletions(pendingXAiPromptCompletionsRef, started.sessionId);532+ yield* runtime.cancel;533+ }),
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 2184OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2061,0 +2164,21 @@2164+ hasOutput: context.assistant.nextSegment > 0,2165+ })2166+ ) {2167+ return;2168+ }2169+ yield* finalizeTurn(context, "completed", undefined, { drainTrailingChunks: true });2170+ });2171+2172+ schedulePromptLivenessWatchdog = (context) =>2173+ Effect.gen(function* () {2174+ const livenessMs = flavor.rootTurnPromptLivenessMs;2175+ if (livenessMs === undefined || livenessMs <= 0) return;2176+ context.promptLivenessGeneration += 1;2177+ const generation = context.promptLivenessGeneration;2178+ yield* Effect.gen(function* () {2179+ yield* Effect.sleep(`${livenessMs} millis`);2180+ if (context.finalized || context.interrupted) return;2181+ if (context.promptLivenessGeneration !== generation) return;2182+ const active = yield* Ref.get(activeTurn);2183+ if (active !== context) return;2184+ if (context.hasRootActivity || acpRootTurnHasIngestedOutput(context)) return;
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 2985OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1460,3 +1527,3 @@14601527 context.pendingSubagentNotifications.set(notification.sessionId, buffered);14611528 return;14621529 }
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 4168OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2061,0 +2148,21 @@2148+ request.runtimeRequest.providerTurnId === context.providerTurnId &&2149+ request.runtimeRequest.status === "pending",2150+ );2151+ const hasRunningTool = [...context.tools.values()].some((tool) => {2152+ const status = toolStatus(tool.status);2153+ return status === "pending" || status === "running";2154+ });2155+ if (2156+ !acpRootTurnIsIdle({2157+ finalized: context.finalized,2158+ interrupted: context.interrupted,2159+ assistantStreamOpen: context.assistant.current !== null,2160+ reasoningStreamOpen: context.reasoning.current !== null,2161+ hasRunningTool,2162+ hasPendingRuntimeRequest,2163+ hasActivePlan: context.plan !== null,2164+ hasOutput: context.assistant.nextSegment > 0,2165+ })2166+ ) {2167+ return;2168+ }
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 4055OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1994,9 +2082,18 @@19942082 completedAt,19952083 });199620842085+ const drainTrailingRootTurnChunks = Effect.fnUntraced(function* () {2086+ if (!flavor.settleRootTurnWhenIdle) return;2087+ // Projected via handleSessionUpdate, not getEvents(). Cooperative yield2088+ // only — replay uses TestClock; Effect.sleep here would stall settlement.2089+ yield* Effect.yieldNow;2090+ yield* Effect.yieldNow;2091+ });2092+19972093 const finalizeTurn = Effect.fnUntraced(function* (19982094 context: ActiveAcpTurn,19992095 status: "completed" | "interrupted" | "failed" | "cancelled",20002096 failure?: OrchestrationV2ProviderFailure,2097+ options?: { readonly drainTrailingChunks?: boolean },20012098 ) {20022099 if (context.finalized) return;apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 4139OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2059,3 +2160,4 @@20592160 yield* Deferred.succeed(context.completed, undefined).pipe(Effect.ignore);20602161 });206121622163+ const trySettleRootTurnWhenIdle = Effect.fnUntraced(function* (context: ActiveAcpTurn) {
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 4171OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2061,0 +2168,21 @@2168+ pending,2169+ );2170+ const hasRunningTool = [...context.tools.values()].some((tool) => {2171+ const status = toolStatus(tool.status);2172+ return status === "pending" || status === "running";2173+ });2174+ if (2175+ !acpRootTurnIsIdle({2176+ finalized: context.finalized,2177+ interrupted: context.interrupted,2178+ assistantStreamOpen: context.assistant.current !== null,2179+ reasoningStreamOpen: context.reasoning.current !== null,2180+ hasRunningTool,2181+ hasPendingRuntimeRequest,2182+ hasOutput: context.assistant.nextSegment > 0,2183+ })2184+ ) {2185+ return;2186+ }2187+ yield* runtime.cancel.pipe(Effect.ignore);2188+ yield* finalizeTurn(context, "completed", undefined, { drainTrailingChunks: true });
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 2191OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -2061,0 +2171,21 @@2171+ });2172+ // Debounce already proved root-session quiescence; open segment handles2173+ // without an explicit close should not block settlement.2174+ if (2175+ !acpRootTurnIsIdle({2176+ finalized: context.finalized,2177+ interrupted: context.interrupted,2178+ assistantStreamOpen: false,2179+ reasoningStreamOpen: false,2180+ hasRunningTool,2181+ hasPendingRuntimeRequest,2182+ hasOutput: context.assistant.nextSegment > 0,2183+ })2184+ ) {2185+ return;2186+ }2187+ yield* finalizeTurn(context, "completed", undefined, { drainTrailingChunks: true });2188+ yield* runtime.cancel.pipe(Effect.ignore);2189+ });2190+2191+ schedulePromptLivenessWatchdog = (context) =>
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 4171OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2061,0 +2167,21 @@2167+ );2168+ const hasRunningTool = [...context.tools.values()].some((tool) => {2169+ const status = toolStatus(tool.status);2170+ return status === "pending" || status === "running";2171+ });2172+ // Debounce already proved root-session quiescence; open segment handles2173+ // without an explicit close should not block settlement.2174+ if (2175+ !acpRootTurnIsIdle({2176+ finalized: context.finalized,2177+ interrupted: context.interrupted,2178+ assistantStreamOpen: false,2179+ reasoningStreamOpen: false,2180+ hasRunningTool,2181+ hasPendingRuntimeRequest,2182+ hasOutput: context.assistant.nextSegment > 0,2183+ })2184+ ) {2185+ return;2186+ }2187+ yield* finalizeTurn(context, "completed", undefined, { drainTrailingChunks: true });
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/server/src/provider/acp/XAiAcpExtension.ts line 1236OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -476,0 +509,21 @@509+ ? Effect.succeed(cancelledResponse)510+ : Effect.failCause(cause),511+ ),512+ ),513+ Deferred.await(fallback.deferred),514+ ).pipe(515+ Effect.tap((response) =>516+ rememberCompletedXAiPromptId(completedXAiPromptIdsRef, response, fallback.promptId),517+ ),518+ Effect.ensuring(519+ Effect.gen(function* () {520+ yield* Fiber.interrupt(promptRpcFiber).pipe(Effect.ignore);521+ yield* unregisterXAiPromptCompletionFallback(522+ pendingXAiPromptCompletionsRef,523+ fallback.deferred,524+ );525+ }),526+ ),527+ );528+ }),529+ cancel: Effect.gen(function* () {
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 2236OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2061,0 +2216,21 @@2216+ ) {2217+ return;2218+ }2219+ yield* finalizeTurn(context, "completed", undefined, { drainTrailingChunks: true });2220+ yield* runtime.cancel.pipe(Effect.ignore);2221+ });2222+2223+ schedulePromptLivenessWatchdog = (context) =>2224+ Effect.gen(function* () {2225+ const livenessMs = flavor.rootTurnPromptLivenessMs;2226+ if (livenessMs === undefined || livenessMs <= 0) return;2227+ context.promptLivenessGeneration += 1;2228+ const generation = context.promptLivenessGeneration;2229+ yield* Effect.gen(function* () {2230+ yield* Effect.sleep(`${livenessMs} millis`);2231+ if (context.finalized || context.interrupted) return;2232+ if (context.promptLivenessGeneration !== generation) return;2233+ const active = yield* Ref.get(activeTurn);2234+ if (active !== context) return;2235+ const pending = yield* Ref.get(pendingRuntimeRequests);2236+ if (acpTurnHasPendingRuntimeRequest(context.providerTurnId, pending)) return;
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 2242OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -2061,0 +2222,21 @@2222+ // without an explicit close should not block settlement.2223+ const hasRunningSubagent = [...context.subagents.values()].some(2224+ (subagent) => subagent.task.status === "running",2225+ );2226+ if (2227+ !acpRootTurnIsIdle({2228+ finalized: context.finalized,2229+ interrupted: context.interrupted,2230+ assistantStreamOpen: false,2231+ reasoningStreamOpen: false,2232+ hasRunningTool,2233+ hasPendingRuntimeRequest,2234+ hasToolHistory: context.tools.size > 0,2235+ hasRunningSubagent,2236+ hasOutput: context.assistant.nextSegment > 0,2237+ })2238+ ) {2239+ return;2240+ }2241+ yield* finalizeTurn(context, "completed", undefined, { drainTrailingChunks: true });2242+ yield* runtime.cancel.pipe(Effect.ignore);
- apps/server/src/provider/acp/AcpRuntimeModel.ts line 462OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -459,3 +459,4 @@459459 return isRecord(meta) && meta.isReplay === true;460460 }461461462+/** Replay chunks and substantive updates during session/load; not Grok keepalives. */apps/server/src/provider/acp/AcpSessionRuntime.ts line 2050OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -817,14 +828,10 @@817828 getConfigOptions: Ref.get(configOptionsRef),818829 loadSession: (sessionId) =>819830 start.pipe(820- Effect.flatMap(() => {831+ Effect.flatMap((started) => {821832 const requestPayload = {822833 sessionId,823834 cwd: options.cwd,824835 mcpServers: options.mcpServers ?? [],825836 } satisfies EffectAcpSchema.LoadSessionRequest;826- return runLoggedRequest(827- "session/load",828- requestPayload,829- acp.agent.loadSession(requestPayload),830- );837+ return runLoadSessionWithReplayIdle(requestPayload, started.initializeResult);
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 4060OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -1995,9 +2132,21 @@19952132 });199621332134+ const drainTrailingRootTurnChunks = Effect.fnUntraced(function* () {2135+ if (!flavor.settleRootTurnWhenIdle) return;2136+ // Projected via handleSessionUpdate, not getEvents(). Cooperative yield2137+ // only — replay uses TestClock; Effect.sleep here would stall settlement.2138+ yield* Effect.yieldNow;2139+ yield* Effect.yieldNow;2140+ });2141+19972142 const finalizeTurn = Effect.fnUntraced(function* (19982143 context: ActiveAcpTurn,19992144 status: "completed" | "interrupted" | "failed" | "cancelled",20002145 failure?: OrchestrationV2ProviderFailure,2146+ options?: { readonly drainTrailingChunks?: boolean },20012147 ) {20022148 if (context.finalized) return;20032149 context.finalized = true;2150+ if (options?.drainTrailingChunks === true) {2151+ yield* drainTrailingRootTurnChunks();2152+ }
- apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.ts line 2999OutdatedResolvedby mwolson(GitHub profile, opens in a new tab)@@ -1465,4 +1572,4 @@14651572 if (update.content.type === "text") {14661573 yield* appendText(context, "assistant", update.content.text);14671574 }1468- return;1575+ break;
- apps/server/src/provider/acp/AcpSessionRuntime.ts line 1582OutdatedResolvedby mwolson(GitHub profile, opens in a new tab)@@ -402,3 +403,3 @@402403 Effect.gen(function* () {403404 const gate = yield* Ref.get(sessionLoadGateRef);404405 if (Option.isSome(gate) && gate.value.active) {apps/server/src/provider/acp/AcpSessionRuntime.ts line 1752OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -545,3 +548,4 @@545548 return nextState;546549 });547550551+ const runLoadSessionWithReplayIdle = (
- apps/server/src/orchestration-v2/ProviderTurnControlService.ts line 172OutdatedResolvedby cursor[bot](GitHub profile, opens in a new tab)@@ -147,3 +147,4 @@147147 yield* loaded.session.value.interruptTurn({148148 providerThread: loaded.providerThread,149149 providerTurnId: loaded.providerTurn.id,150+ requestRuntimeRestart: true,
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
Run ID:
852efc54-1c5a-472b-a05a-a9e96d1db6feYou can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.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.
❤️ Share