From f94ad43c6079d5975dcb4c7abd18472e2ae4752c Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Tue, 17 Nov 2026 17:54:58 +0100 Subject: [PATCH 1/3] test(server): images from refused Claude starts survive a lost native session Co-authored-by: Claude Opus 5.5 --- .../testkit/ProviderSwitch.integration.test.ts | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts b/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts index 7aa0a1a2631fb..1a49275d9f2d6 100644 --- a/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts +++ b/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts @@ -1971,9 +1971,16 @@ describe("orchestration v2 provider switching", () => { new ClaudeBackgroundWorkBlocksQueryReplacementError(), true, ], - ] as const)("keeps the native session after turns refused for %s", ([, refusalCause, inject]) => + [ + "background work followed by a lost native session", + new ClaudeBackgroundWorkBlocksQueryReplacementError(), + false, + true, + ], + ] as const)("retains missed images after %s", ([, refusalCause, inject, loseSession]) => Effect.gen(function* () { const cwd = yield* checkpointWorkspace("refused-start-keeps-native"); + const failResumeOnce = yield* Ref.make(false); const capturedTurns = yield* Ref.make>([]); const injectedHistory = yield* Ref.make>([]); const refuseStarts = yield* Ref.make(0); @@ -1988,6 +1995,7 @@ describe("orchestration v2 provider switching", () => { capturedTurns, refuseStarts, refusalCause, + failResumeOnce, nativeThreadGeneration: generation, ...(inject === true ? { injectedHistory } : {}), }), @@ -2045,12 +2053,15 @@ describe("orchestration v2 provider switching", () => { yield* Ref.set(refuseStarts, 2); assert.equal(yield* run(2), "failed"); assert.equal(yield* run(3), "failed"); + yield* Ref.set(failResumeOnce, loseSession === true); assert.equal(yield* run(4), "completed"); const turns = yield* Ref.get(capturedTurns); assert.equal(turns.length, 2); - assert.equal(yield* Ref.get(generation), 1); - assert.equal(turns[1]?.nativeThreadId, turns[0]?.nativeThreadId); + assert.equal(yield* Ref.get(generation), loseSession === true ? 2 : 1); + if (loseSession !== true) { + assert.equal(turns[1]?.nativeThreadId, turns[0]?.nativeThreadId); + } const delivered = `${turns[1]?.text}${JSON.stringify(yield* Ref.get(injectedHistory))}`; assert.include(delivered, "Request 2"); assert.include(delivered, "Request 3"); From 01d8382a89a9dd1eec349c1da2269c432ab874b5 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Tue, 17 Nov 2026 17:57:25 +0100 Subject: [PATCH 2/3] fix(server): images from refused Claude starts survive a fresh-session recovery Co-authored-by: Claude Opus 5.5 --- .../src/orchestration-v2/ProviderTurnStartService.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/apps/server/src/orchestration-v2/ProviderTurnStartService.ts b/apps/server/src/orchestration-v2/ProviderTurnStartService.ts index 21f4000577926..28f8f474cd6ab 100644 --- a/apps/server/src/orchestration-v2/ProviderTurnStartService.ts +++ b/apps/server/src/orchestration-v2/ProviderTurnStartService.ts @@ -1049,11 +1049,8 @@ export const layer: Layer.Layer< ...loadedProviderThread, contextUsage: handoffUsage, }; - // The resume fallback summary already covers every earlier run in order. A - // retry copy after it would rank older missed requests as the newest history. const missedRuns = projection.runs.filter( (source) => - !resumeFellBack && source.ordinal < run.ordinal && source.providerThreadId === providerThread.id && (source.status === "failed" || source.status === "interrupted") && @@ -1097,8 +1094,10 @@ export const layer: Layer.Layer< const missedItems = missedHistory.filter( (item) => !coveredItemIds.has(item.id) && historicalMessage(item) !== null, ); + // The resume fallback summary already covers every earlier run in order. A + // retry copy after it would rank older missed requests as the newest history. const handoffs = - missedItems.length === 0 + missedItems.length === 0 || resumeFellBack ? [] : [ yield* contextHandoffService.prepareProviderHandoff({ @@ -1494,7 +1493,7 @@ export const layer: Layer.Layer< } } resumedHandoffContext = undefined; - resumedRetryHandoff = { handoffs: [], attachments: [] }; + resumedRetryHandoff = undefined; if (!(yield* isCurrentAttemptInStatus("starting"))) return undefined; // Another client is still writing to the native thread. A fresh // session here would silently split the conversation from it. From 90dce07896b191d72d3b7a16adcd3af3a67f86a4 Mon Sep 17 00:00:00 2001 From: Wout Stiens <71498452+StiensWout@users.noreply.github.com> Date: Tue, 17 Nov 2026 18:04:49 +0100 Subject: [PATCH 3/3] chore: credit the models that worked on this change Co-authored-by: Grok 4.7 Co-authored-by: GPT 6.1 Sol