diff --git a/apps/server/src/orchestration-v2/ProviderTurnStartService.ts b/apps/server/src/orchestration-v2/ProviderTurnStartService.ts index 742f31d4c1006..93be5dd9cc1a1 100644 --- a/apps/server/src/orchestration-v2/ProviderTurnStartService.ts +++ b/apps/server/src/orchestration-v2/ProviderTurnStartService.ts @@ -1274,7 +1274,13 @@ export const layer: Layer.Layer< source.activeAttemptId !== null && acceptedAttemptIds.has(source.activeAttemptId), ); - if (previous?.status !== "failed") return false; + if ( + previous === undefined || + (previous.status !== "failed" && + previous.status !== "interrupted" && + previous.status !== "cancelled") + ) + return false; const previousAttempt = projection.attempts.find( (source) => source.id === previous.activeAttemptId, ); 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 5e4af84f4b342..1e06d40658aad 100644 --- a/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts +++ b/apps/server/src/orchestration-v2/testkit/ProviderSwitch.integration.test.ts @@ -1245,6 +1245,8 @@ describe("orchestration v2 provider switching", () => { "live", "detached", "legacy", + "interrupted", + "cancelled", "other-error", "other-provider", "repaired-native", @@ -1364,6 +1366,19 @@ describe("orchestration v2 provider switching", () => { ), }); } + if (scenario === "interrupted" || scenario === "cancelled") { + yield* (yield* EventSink.EventSinkV2).write({ + events: [ + { + id: EventId.make(`rejected:${scenario}`), + type: "run.updated", + threadId, + occurredAt: failed.thread.createdAt, + payload: { ...failed.runs.at(-1)!, status: scenario }, + }, + ], + }); + } if (scenario === "repaired-native") { const providerThread = failed.providerThreads[0]!; yield* (yield* EventSink.EventSinkV2).write({