Skip to content

Commit 10d2a22

Browse files
committed
fix(acp): 新指令发送前失效旧投递记录
- 在发送替代指令前清除持久与进程内旧状态,避免模式切换失败后错误复用旧指令。 - 添加同一进程及重开会话后的 Plan 模式回归用例,确认失败后重新注入。 - 100 项跨适配器回放测试与包含新增用例的 check:changed 均通过。
1 parent 6072d28 commit 10d2a22

2 files changed

Lines changed: 31 additions & 2 deletions

File tree

‎apps/server/src/orchestration-v2/Adapters/AcpAdapterV2.test.ts‎

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,9 @@ const makeInstructionCompactionHarness = Effect.fnUntraced(function* (
381381
messageText: string,
382382
expectedStatus = "completed",
383383
reopen = false,
384+
interactionMode: "default" | "plan" = "default",
384385
) {
386+
const turnRuntimePolicy = { ...runtimePolicy, interactionMode };
385387
if (reopen) {
386388
const nativeSessionId = providerThread.nativeThreadRef?.nativeId;
387389
if (nativeSessionId == null) return yield* Effect.die("Expected a persisted native session");
@@ -390,7 +392,7 @@ const makeInstructionCompactionHarness = Effect.fnUntraced(function* (
390392
providerThread = yield* session.runtime.resumeThread({
391393
providerThread,
392394
modelSelection,
393-
runtimePolicy,
395+
runtimePolicy: turnRuntimePolicy,
394396
});
395397
}
396398
const { runtime } = session;
@@ -399,7 +401,7 @@ const makeInstructionCompactionHarness = Effect.fnUntraced(function* (
399401
threadId,
400402
providerThread,
401403
instanceId,
402-
runtimePolicy,
404+
runtimePolicy: turnRuntimePolicy,
403405
now,
404406
ordinal: ++ordinal,
405407
messageText,
@@ -1047,6 +1049,25 @@ describe("AcpAdapterV2", () => {
10471049
}).pipe(Effect.provide(layerTest), Effect.scoped),
10481050
);
10491051

1052+
it.live.each([false, true])(
1053+
"invalidates old instructions after a failed mode change (reopen: %s)",
1054+
(reopen) =>
1055+
Effect.gen(function* () {
1056+
const runTurn = yield* makeInstructionCompactionHarness({
1057+
T3_ACP_FAIL_PROMPT_ORDINAL: "2",
1058+
});
1059+
assert.include(
1060+
(yield* runTurn("Plan first.", "completed", false, "plan"))[0]?.text ?? "",
1061+
"T3 Code interaction mode: Plan",
1062+
);
1063+
yield* runTurn("Implement now.", "failed");
1064+
assert.include(
1065+
(yield* runTurn("Plan again.", "completed", reopen, "plan"))[0]?.text ?? "",
1066+
"T3 Code interaction mode: Plan",
1067+
);
1068+
}).pipe(Effect.provide(layerTest), Effect.scoped),
1069+
);
1070+
10501071
it.live("records instructions before ACP work-state completion ends the run", () =>
10511072
Effect.gen(function* () {
10521073
const runTurn = yield* makeInstructionCompactionHarness(

‎packages/provider-acp/src/server/adapter.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7559,6 +7559,14 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
75597559
return;
75607560
}
75617561
const promptGeneration = yield* Ref.get(runtimeCallbackGeneration);
7562+
if (promptParts?.instructionState !== undefined) {
7563+
yield* recordInstructions(context, null);
7564+
yield* Ref.update(promptInstructionStates, (current) => {
7565+
const updated = new Map(current);
7566+
updated.delete(requestedSessionId);
7567+
return updated;
7568+
});
7569+
}
75627570
yield* runtime.prompt({ prompt: promptParts!.prompt }).pipe(
75637571
Effect.tap(() =>
75647572
Ref.update(promptInstructionStates, (current) => {

0 commit comments

Comments
 (0)