@devries-cameron20 / t3code Mirror · read-only / commits / e7b61491a3
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

fix(server): a delivered handoff of a failed run is not re-sent to later fresh sessions (#39281)

Julius Marminge committed Nov 19, 2026 at 12:33 UTC e7b61491a3a93c2562c95d60c281c81c71c00688
2 files changed +15 -3
apps/server/src/orchestration-v2/ProviderTurnStartService.ts
+13 -2
@@ -549,9 +549,20 @@ export const layer: Layer.Layer<
549 projection.runs.some(
550 (source) =>
551 source.id === handoff.targetRunId &&
552 - (source.status === "failed" ||
552 + // A settled delivery retires history of this thread: the session that took it
553 + // holds it, and a fresh session starts from a full summary of the thread. That
554 + // summary lacks another thread's history (a fork source, a merge-back).
555 + (((source.status === "failed" ||
556 source.status === "interrupted" ||
554 - source.status === "cancelled" ||
557 + source.status === "cancelled") &&
558 + !(
559 + (handoff.delivery?.status === "injected" ||
560 + handoff.delivery?.status === "inline") &&
561 + handoff.fromProviderThreadIds.length > 0 &&
562 + handoff.fromProviderThreadIds.every((id) =>
563 + projection.providerThreads.some((candidate) => candidate.id === id),
564 + )
565 + )) ||
566 (source.status === "completed" &&
567 handoff.delivery === undefined &&
568 // Compaction and /goal turns defer history to the next turn.
apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts
+2 -1
@@ -2212,7 +2212,8 @@ describe("orchestration v2 provider switching", () => {
2212 ["completed", "failed", "completed", "completed"],
2213 );
2214 const run4NativeThreadId = (yield* Ref.get(capturedTurns)).at(-1)?.nativeThreadId;
2215 - assert.equal(
2215 + // Run 3's summary already covers run 2's handoff, so run 4's fresh session must not get it again.
2216 + assert.notEqual(
2217 projection.contextHandoffs.find(
2218 (handoff) => handoff.targetRunId === projection.runs[1]?.id,
2219 )?.delivery?.nativeThreadId,