Skip to content

Commit 526243f

Browse files
refactor(server): rely on recorded legacy history delivery
1 parent b98c2f8 commit 526243f

1 file changed

Lines changed: 9 additions & 19 deletions

File tree

‎apps/server/src/orchestration-v2/Orchestrator.ts‎

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,6 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
969969
const legacyImportCovered = Effect.fnUntraced(function* (
970970
threadId: ThreadId,
971971
providerThread: OrchestrationV2ProviderThread | undefined,
972-
runs: ReadonlyArray<OrchestrationV2Run>,
973972
) {
974973
if (providerThread === undefined) return false;
975974
const { contextHandoffs } = yield* projectionStore.getThreadRecords(threadId, [
@@ -985,18 +984,11 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
985984
) {
986985
return false;
987986
}
988-
if (handoff.delivery !== undefined) {
989-
return (
990-
nativeId !== undefined &&
991-
handoff.delivery.nativeThreadId === nativeId &&
992-
handoff.delivery.status !== "pending"
993-
);
994-
}
995-
// Turn start retries undelivered handoffs from failed or interrupted runs.
996-
return runs.some(
997-
(run) =>
998-
run.id === handoff.targetRunId &&
999-
(run.status === "failed" || run.status === "interrupted"),
987+
return (
988+
nativeId !== undefined &&
989+
handoff.delivery !== undefined &&
990+
handoff.delivery.nativeThreadId === nativeId &&
991+
handoff.delivery.status !== "pending"
1000992
);
1001993
});
1002994
});
@@ -5422,11 +5414,9 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
54225414
hasCompletedRun: latestCompletedRun !== undefined,
54235415
legacyImportItemCount: legacyImportItems.length,
54245416
}) &&
5425-
!(yield* legacyImportCovered(
5426-
command.threadId,
5427-
activeProviderThread,
5428-
projection.runs,
5429-
).pipe(mapDispatchError(command)))
5417+
!(yield* legacyImportCovered(command.threadId, activeProviderThread).pipe(
5418+
mapDispatchError(command),
5419+
))
54305420
? yield* contextHandoffService
54315421
.prepareLegacyImport({
54325422
threadId: command.threadId,
@@ -6038,7 +6028,7 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
60386028
!canResumeAcrossInstances &&
60396029
latestCompletedRun === undefined &&
60406030
legacyImportItems.length > 0 &&
6041-
!(yield* legacyImportCovered(command.threadId, ensuredProviderThread, projection.runs).pipe(
6031+
!(yield* legacyImportCovered(command.threadId, ensuredProviderThread).pipe(
60426032
mapDispatchError(command),
60436033
))
60446034
? yield* contextHandoffService

0 commit comments

Comments
 (0)