Skip to content

Commit 9297edf

Browse files
fix(acp): invalidate instruction receipts after focused /compact
AI-assisted; verified with the tests and tools listed above. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 5a78f25 commit 9297edf

2 files changed

Lines changed: 14 additions & 3 deletions

File tree

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,7 @@ describe("AcpAdapterV2", () => {
22482248
}).pipe(Effect.provide(layerTest), Effect.scoped),
22492249
);
22502250

2251-
it.live.each(["native", "protocol"] as const)(
2251+
it.live.each(["native", "focused", "protocol"] as const)(
22522252
"retains ACP instructions across reopen but reinjects after %s compaction",
22532253
(compaction) =>
22542254
Effect.gen(function* () {
@@ -2264,7 +2264,13 @@ describe("AcpAdapterV2", () => {
22642264
(yield* runTurn("Continue work.", "completed", true))[0]?.text,
22652265
"Continue work.",
22662266
);
2267-
yield* runTurn(compaction === "native" ? "/compact" : "Compact while working.");
2267+
yield* runTurn(
2268+
compaction === "native"
2269+
? "/compact"
2270+
: compaction === "focused"
2271+
? "/compact keep the plan"
2272+
: "Compact while working.",
2273+
);
22682274
assertReinjectedInstructions(
22692275
yield* runTurn("Continue after compact.", "completed", true),
22702276
"Continue after compact.",

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,11 @@ function isCompactionMessage(message: ProviderAdapter.ProviderAdapterV2TurnMessa
826826
return message.text.trim() === "/compact" && message.attachments.length === 0;
827827
}
828828

829+
// Agents also accept `/compact <focus>`; it compacts history even though it is sent as a prompt.
830+
function isCompactionCommand(message: ProviderAdapter.ProviderAdapterV2TurnMessage): boolean {
831+
return /^\/compact(?:\s|$)/.test(message.text.trim()) && message.attachments.length === 0;
832+
}
833+
829834
function negotiatedCapabilities(
830835
base: OrchestrationV2ProviderCapabilities,
831836
started: AcpSessionRuntime.AcpSessionRuntimeStartResult,
@@ -7822,7 +7827,7 @@ export const makeAcpAdapterV2 = Effect.fn("makeAcpAdapterV2")(function* (
78227827
}
78237828
if (
78247829
(flavor.supportsCompaction === true || flavor.compactSession !== undefined) &&
7825-
isCompactionMessage(context.input.message) &&
7830+
isCompactionCommand(context.input.message) &&
78267831
settledStatus === "completed"
78277832
) {
78287833
const nativeItemId = `${context.nativeTurnId}:compaction`;

0 commit comments

Comments
 (0)