Skip to content

Commit 3735605

Browse files
committed
fix(server): avoid replaying imported ACP history into its native session
1 parent 8e0a44c commit 3735605

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ it("reissues imported context until a V2 run completes", () => {
1010
legacyImportItemCount: 2,
1111
}),
1212
);
13+
assert.isFalse(
14+
shouldPrepareLegacyImportHandoff({
15+
historyOrigin: "v1_import",
16+
hasCompletedRun: false,
17+
legacyImportItemCount: 2,
18+
hasNativeHistory: true,
19+
}),
20+
);
1321
assert.isFalse(
1422
shouldPrepareLegacyImportHandoff({
1523
historyOrigin: "v1_import",

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -956,12 +956,16 @@ function latestContextTransfer(
956956
}
957957

958958
export function shouldPrepareLegacyImportHandoff(input: {
959+
readonly hasNativeHistory?: boolean;
959960
readonly hasCompletedRun: boolean;
960961
readonly historyOrigin: OrchestrationV2AppThread["historyOrigin"];
961962
readonly legacyImportItemCount: number;
962963
}): boolean {
963964
return (
964-
input.historyOrigin === "v1_import" && !input.hasCompletedRun && input.legacyImportItemCount > 0
965+
input.historyOrigin === "v1_import" &&
966+
!input.hasNativeHistory &&
967+
!input.hasCompletedRun &&
968+
input.legacyImportItemCount > 0
965969
);
966970
}
967971

@@ -6248,6 +6252,9 @@ const makeOrchestrator = Effect.fn("orchestrationV2.Orchestrator.layer")(functio
62486252
nativeThreadId: `pending:${runId}`,
62496253
});
62506254
const legacyImportHandoff = shouldPrepareLegacyImportHandoff({
6255+
hasNativeHistory:
6256+
activeProviderThread?.driver === "acpRegistry" &&
6257+
activeProviderThread.nativeThreadRef !== null,
62516258
historyOrigin: projection.thread.historyOrigin,
62526259
hasCompletedRun: latestCompletedRun !== undefined,
62536260
legacyImportItemCount: legacyImportItems.length,

0 commit comments

Comments
 (0)