The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 17:15 UTC
fix(acp): v2 tool updates clear nulled fields and replace raw input (#35869)
Julius Marminge committed
Nov 12, 2026 at 20:00 UTC
ed5afae1792f5ef437b1970f98a8cb1046f63396
6 files changed
+97
-16
packages/effect-acp/src/client.test.ts
+13
-4
@@ -1608,7 +1608,7 @@ it.layer(NodeServices.layer)("effect-acp client", (it) => {
1608
}),
1609
);
1610
1611
- it.effect("delivers ACP v1 session notices, which the pinned v1 schema predates", () =>
1611
+ it.effect("normalizes ACP v1 session notices and null tool names to v2 semantics", () =>
1612
Effect.gen(function* () {
1613
const { stdio, input, output } = yield* makeInMemoryStdio();
1614
const scope = yield* Scope.make();
@@ -1636,7 +1636,12 @@ it.layer(NodeServices.layer)("effect-acp client", (it) => {
1636
description: "Continuing without it.",
1637
} as const;
1638
const untitled = { sessionUpdate: "notice", severity: "info" } as const;
1639
- for (const update of [notice, untitled]) {
1639
+ const toolUpdate = {
1640
+ sessionUpdate: "tool_call_update",
1641
+ toolCallId: "c",
1642
+ status: "completed",
1643
+ };
1644
+ for (const update of [notice, untitled, { ...toolUpdate, name: null }]) {
1645
yield* Queue.offer(
1646
input,
1647
yield* encodeJsonl(SessionUpdateNotification, {
@@ -1646,12 +1651,16 @@ it.layer(NodeServices.layer)("effect-acp client", (it) => {
1651
}),
1652
);
1653
}
1649
- const received = yield* acp.raw.notifications.pipe(Stream.take(2), Stream.runCollect);
1654
+ const received = yield* acp.raw.notifications.pipe(Stream.take(3), Stream.runCollect);
1655
assert.deepEqual(
1656
Array.from(received, (event) =>
1657
event._tag === "SessionUpdate" ? event.params.update : undefined,
1658
),
1654
- [notice, { sessionUpdate: "_t3_unknown", originalSessionUpdate: "notice", raw: untitled }],
1659
+ [
1660
+ notice,
1661
+ { sessionUpdate: "_t3_unknown", originalSessionUpdate: "notice", raw: untitled },
1662
+ toolUpdate,
1663
+ ],
1664
);
1665
yield* Scope.close(scope, Exit.void);
1666
}),
packages/effect-acp/src/client.ts
+9
@@ -528,6 +528,15 @@ function normalizeV1SessionUpdate(
528
},
529
};
530
}
531
+ const update = notification.update;
532
+ // v1 defines a null tool name as unchanged; v2 consumers read null as a clear.
533
+ if (
534
+ (update.sessionUpdate === "tool_call" || update.sessionUpdate === "tool_call_update") &&
535
+ update.name === null
536
+ ) {
537
+ const { name: _name, ...rest } = update;
538
+ return { ...notification, update: rest } as unknown as AcpSchema.SessionNotification;
539
+ }
540
if (notification.update.sessionUpdate !== "available_commands_update") {
541
return notification as unknown as AcpSchema.SessionNotification;
542
}
packages/provider-acp/src/server/runtimeModel.test.ts
+44
@@ -361,6 +361,50 @@ describe("AcpRuntimeModel", () => {
361
).toBe(true);
362
});
363
364
+ it("clears explicitly nulled ACP v2 tool call fields and replaces raw input", () => {
365
+ const toolCall = (update: Omit<EffectAcpSchema.ToolCallUpdate, "toolCallId">) => {
366
+ const parsed = parseSessionUpdateEvent({
367
+ sessionId: "session-1",
368
+ update: { sessionUpdate: "tool_call_update", toolCallId: "call-1", ...update },
369
+ } satisfies EffectAcpSchema.SessionNotification);
370
+ const event = parsed.events.find((candidate) => candidate._tag === "ToolCallUpdated");
371
+ if (!event || event._tag !== "ToolCallUpdated") {
372
+ throw new Error("expected a tool call update");
373
+ }
374
+ return event.toolCall;
375
+ };
376
+
377
+ const created = toolCall({
378
+ name: "old-name",
379
+ title: "Old title",
380
+ kind: "read",
381
+ status: "in_progress",
382
+ content: [{ type: "content", content: { type: "text", text: "old output" } }],
383
+ rawInput: { path: "old.txt", obsolete: true },
384
+ _meta: { old: true },
385
+ });
386
+
387
+ expect(
388
+ mergeToolCallState(created, toolCall({ rawInput: { path: "new.txt" } })).data.rawInput,
389
+ ).toEqual({ path: "new.txt" });
390
+
391
+ const cleared = mergeToolCallState(
392
+ created,
393
+ toolCall({
394
+ name: null,
395
+ title: null,
396
+ kind: null,
397
+ status: null,
398
+ content: null,
399
+ rawInput: null,
400
+ _meta: null,
401
+ }),
402
+ );
403
+ const { name, title, kind, content, rawInput, meta } = cleared.data;
404
+ expect({ name, title, kind, content, rawInput, meta }).toEqual({});
405
+ expect({ kind: cleared.kind, title: cleared.title, status: cleared.status }).toEqual({});
406
+ });
407
+
408
it("forwards an empty ACP v1 plan to clear previous entries", () => {
409
const entries = [
410
[{ content: "Inspect state", priority: "high", status: "pending" }],
packages/provider-acp/src/server/runtimeModel.ts
+16
-3
@@ -842,6 +842,19 @@ function makeToolCallState(
842
? title
843
: undefined;
844
const data: Record<string, unknown> = { toolCallId };
845
+ // ACP v2 clears a field set to null; mergeToolCallState consumes these markers.
846
+ const clearable = {
847
+ name: input.name,
848
+ title: input.title,
849
+ kind: input.kind,
850
+ status: input.status,
851
+ content: input.content,
852
+ rawInput: input.rawInput,
853
+ meta: input._meta,
854
+ };
855
+ for (const [key, value] of Object.entries(clearable)) {
856
+ if (value === null) data[key] = null;
857
+ }
858
if (input.name != null) data.name = input.name;
859
if (kind) {
860
data.kind = kind;
@@ -929,9 +942,9 @@ export function mergeToolCallState(
942
next: AcpToolCallState,
943
): AcpToolCallState {
944
const nextKind = next.kind ?? (typeof next.data.kind === "string" ? next.data.kind : undefined);
932
- const kind = nextKind ?? previous?.kind;
933
- const title = next.title ?? previous?.title;
934
- const status = next.status ?? previous?.status;
945
+ const kind = next.data.kind === null ? nextKind : (nextKind ?? previous?.kind);
946
+ const title = next.data.title === null ? next.title : (next.title ?? previous?.title);
947
+ const status = next.data.status === null ? next.status : (next.status ?? previous?.status);
948
const command = next.command ?? previous?.command;
949
const detail = next.detail ?? previous?.detail;
950
const data = mergeToolActivityData(previous?.data, next.data) ?? next.data;
packages/shared/src/toolActivity.test.ts
+2
-2
@@ -22,7 +22,7 @@ describe("toolActivity", () => {
22
);
23
});
24
25
- it("keeps the first non-empty rawInput when a later update is empty", () => {
25
+ it("keeps the previous rawInput when a later update is empty and replaces it otherwise", () => {
26
expect(
27
mergeToolActivityData({ rawInput: { path: "src/a.ts" } }, { rawInput: {}, kind: "read" }),
28
).toEqual({
@@ -31,7 +31,7 @@ describe("toolActivity", () => {
31
});
32
expect(
33
mergeToolActivityData({ rawInput: { path: "src/a.ts" } }, { rawInput: { startLine: 4 } }),
34
- ).toEqual({ rawInput: { path: "src/a.ts", startLine: 4 } });
34
+ ).toEqual({ rawInput: { startLine: 4 } });
35
});
36
37
it("recognizes computer-use REPL calls before result metadata exists", () => {
packages/shared/src/toolActivity.ts
+13
-7
@@ -194,7 +194,10 @@ function extractPrimaryPath(data: Record<string, unknown> | undefined): string |
194
return collectToolFilePaths(data)[0];
195
}
196
197
-/** Preserve the first nonempty rawInput; later ACP updates often resend an empty object. */
197
+/**
198
+ * A null field clears it (ACP v2) and a nonempty rawInput replaces the previous one.
199
+ * An empty rawInput keeps the previous one; later ACP updates often resend an empty object.
200
+ */
201
export function mergeToolActivityData(
202
previous: unknown,
203
next: unknown,
@@ -204,15 +207,18 @@ export function mergeToolActivityData(
207
if (!nextRecord) {
208
return previousRecord;
209
}
207
- if (!previousRecord) {
208
- return nextRecord;
210
+ const merged = { ...previousRecord, ...nextRecord };
211
+ for (const [key, value] of Object.entries(merged)) {
212
+ if (value === null) {
213
+ delete merged[key];
214
+ }
215
+ }
216
+ if (!previousRecord || nextRecord.rawInput === null) {
217
+ return merged;
218
}
219
const previousInput = asRecord(previousRecord.rawInput);
220
const nextInput = asRecord(nextRecord.rawInput);
212
- const rawInput = recordHasKeys(nextInput)
213
- ? { ...previousInput, ...nextInput }
214
- : (previousInput ?? nextInput);
215
- const merged = { ...previousRecord, ...nextRecord };
221
+ const rawInput = recordHasKeys(nextInput) ? nextInput : (previousInput ?? nextInput);
222
if (recordHasKeys(rawInput)) {
223
merged.rawInput = rawInput;
224
} else {