Skip to content

Commit 9522c7d

Browse files
authored
fix(acp): forward empty plan replacements (#23440)
1 parent 3a537d2 commit 9522c7d

2 files changed

Lines changed: 38 additions & 11 deletions

File tree

‎packages/provider-acp/src/server/runtimeModel.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,35 @@ describe("AcpRuntimeModel", () => {
329329
).toBe(true);
330330
});
331331

332+
it("forwards an empty ACP v1 plan to clear previous entries", () => {
333+
const entries = [
334+
[{ content: "Inspect state", priority: "high", status: "pending" }],
335+
[],
336+
] as const;
337+
const updates = entries.flatMap(
338+
(plan) =>
339+
parseSessionUpdateEvent({
340+
sessionId: "session-1",
341+
update: { sessionUpdate: "plan", entries: plan },
342+
}).events,
343+
);
344+
345+
expect(updates).toMatchObject([
346+
{
347+
_tag: "PlanUpdated",
348+
payload: {
349+
nativePlanId: "legacy",
350+
kind: "items",
351+
plan: [{ step: "Inspect state", status: "pending" }],
352+
},
353+
},
354+
{
355+
_tag: "PlanUpdated",
356+
payload: { nativePlanId: "legacy", kind: "items", plan: [] },
357+
},
358+
]);
359+
});
360+
332361
it("projects typed ACP plan and content updates", () => {
333362
const planResult = parseSessionUpdateEvent({
334363
sessionId: "session-1",

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,17 +1392,15 @@ export function parseSessionUpdateEvent(params: EffectAcpSchema.SessionNotificat
13921392
step: entry.content.trim().length > 0 ? entry.content.trim() : `Step ${index + 1}`,
13931393
status: normalizePlanStepStatus(entry.status),
13941394
}));
1395-
if (plan.length > 0) {
1396-
events.push({
1397-
_tag: "PlanUpdated",
1398-
payload: {
1399-
nativePlanId: "legacy",
1400-
kind: "items",
1401-
plan,
1402-
},
1403-
rawPayload: params,
1404-
});
1405-
}
1395+
events.push({
1396+
_tag: "PlanUpdated",
1397+
payload: {
1398+
nativePlanId: "legacy",
1399+
kind: "items",
1400+
plan,
1401+
},
1402+
rawPayload: params,
1403+
});
14061404
break;
14071405
}
14081406
case "plan_update": {

0 commit comments

Comments
 (0)