@devries-cameron20 / t3code-1 / commits / d756fed7aa
Fork 0

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

fix(server): provider switches hand off started cancelled runs (#34016)

Julius Marminge committed Nov 10, 2026 at 11:55 UTC d756fed7aaac06134bc68cbe0047e6f14b0e9aa2
2 files changed +15 -3
apps/server/src/orchestration-v2/Orchestrator.ts
+7 -1
@@ -1101,7 +1101,13 @@ function rootProviderThreadsForProvider(
1101 }
1102
1103 function isHandoffSourceRun(run: OrchestrationV2Run): boolean {
1104 - return run.status === "completed" || run.status === "failed" || run.status === "interrupted";
1104 + return (
1105 + run.status === "completed" ||
1106 + run.status === "failed" ||
1107 + run.status === "interrupted" ||
1108 + // A queued request cancelled before it started never reached any provider.
1109 + (run.status === "cancelled" && run.startedAt !== null)
1110 + );
1111 }
1112
1113 function lastDeliveredRunForProviderThread(
apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts
+8 -2
@@ -114,6 +114,7 @@ function makeTestAdapter(input: {
114 readonly failure?: ReturnType<typeof makeProviderFailure>;
115 readonly failedRunOrdinals?: ReadonlySet<number>;
116 readonly interruptedRunOrdinals?: ReadonlySet<number>;
117 + readonly cancelledRunOrdinals?: ReadonlySet<number>;
118 readonly holdRunOrdinal?: number;
119 readonly pendingBackgroundWork?: Ref.Ref<boolean>;
120 readonly subagentOnlyBackgroundWork?: boolean;
@@ -295,7 +296,9 @@ function makeTestAdapter(input: {
296 ? "failed"
297 : input.interruptedRunOrdinals?.has(turnInput.runOrdinal)
298 ? "interrupted"
298 - : "completed";
299 + : input.cancelledRunOrdinals?.has(turnInput.runOrdinal)
300 + ? "cancelled"
301 + : "completed";
302 const response =
303 input.responseByThreadId?.[turnInput.threadId]?.[turnInput.runOrdinal] ??
304 input.responseByRunOrdinal[turnInput.runOrdinal] ??
@@ -1587,6 +1590,8 @@ describe("orchestration v2 provider switching", () => {
1590 ["failed", true, true, true],
1591 ["interrupted", false, true, false],
1592 ["interrupted", true, false, true],
1593 + ["cancelled", false, false, false],
1594 + ["cancelled", true, true, false],
1595 ] as const
1596 ).map(
1597 ([status, queued, returning, native]) =>
@@ -1631,6 +1636,7 @@ describe("orchestration v2 provider switching", () => {
1636 interruptedRunOrdinals: new Set(
1637 status === "interrupted" ? [sourceOrdinal] : [],
1638 ),
1639 + cancelledRunOrdinals: new Set(status === "cancelled" ? [sourceOrdinal] : []),
1640 holdRunOrdinal: sourceOrdinal,
1641 holdFirstTurn: started,
1642 releaseFirstTurn: release,
@@ -1644,7 +1650,7 @@ describe("orchestration v2 provider switching", () => {
1650 const worker = yield* EffectWorker.OrchestrationEffectWorkerV2;
1651 const waitForRun = (
1652 ordinal: number,
1647 - expectedStatus: "completed" | "failed" | "interrupted",
1653 + expectedStatus: "completed" | "failed" | "interrupted" | "cancelled",
1654 ) =>
1655 orchestrator.streamStoredEvents.pipe(
1656 Stream.filter(