The best way to control Claude Code, Codex and more from any computer or phone
fix(acp): one malformed session update no longer ends the session (#20015)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 15, 2026 at 14:21 UTC
559c4b1f2192a17060c698f014074a223cbcf7bd
8 files changed
+326
-65
apps/server/src/orchestration-v2/testkit/fixtures/index.ts
+17
@@ -128,6 +128,8 @@ import { skillInvocationInput } from "./skill_invocation/input.ts";
128
import { assertSimpleOutput } from "./simple/codex_output.ts";
129
import { assertPiSimpleOutput } from "./simple/pi_output.ts";
130
import { simpleInput } from "./simple/input.ts";
131
+import { malformedSessionUpdateInput } from "./malformed_session_update/input.ts";
132
+import { assertMalformedSessionUpdateOutput } from "./malformed_session_update/output.ts";
133
import { assertSubagentOutput } from "./subagent/codex_output.ts";
134
import { assertClaudeSubagentOutput } from "./subagent/claude_output.ts";
135
import { subagentInput } from "./subagent/input.ts";
@@ -594,6 +596,21 @@ export const ORCHESTRATOR_REPLAY_FIXTURES: ReadonlyArray<OrchestratorReplayFixtu
596
},
597
],
598
},
599
+ {
600
+ name: "malformed_session_update",
601
+ buildInput: malformedSessionUpdateInput,
602
+ providers: [
603
+ {
604
+ driver: ProviderDriverKind.make("acpRegistry"),
605
+ transcriptFile: new URL(
606
+ "./malformed_session_update/registry_transcript.ndjson",
607
+ import.meta.url,
608
+ ),
609
+ modelSelection: ACP_REGISTRY_MODEL_SELECTION,
610
+ assertOutput: assertMalformedSessionUpdateOutput,
611
+ },
612
+ ],
613
+ },
614
{
615
name: "simple",
616
buildInput: simpleInput,
apps/server/src/orchestration-v2/testkit/fixtures/malformed_session_update/input.ts
new
+15
@@ -0,0 +1,15 @@
1
+import type { OrchestratorFixtureInput } from "../shared.ts";
2
+
3
+export const MALFORMED_SESSION_UPDATE_PROMPT =
4
+ "Respond with the following text: malformed update fixture ok";
5
+
6
+/**
7
+ * An agent sends a `usage_update` without the required `used` and `size`
8
+ * mid-turn, the way clanka did (reported 2026-10-15). T3 drops that one
9
+ * update and the turn completes with the text and usage that follow it.
10
+ */
11
+export function malformedSessionUpdateInput(): OrchestratorFixtureInput {
12
+ return {
13
+ steps: [{ type: "message", text: MALFORMED_SESSION_UPDATE_PROMPT }],
14
+ };
15
+}
apps/server/src/orchestration-v2/testkit/fixtures/malformed_session_update/output.ts
new
+30
@@ -0,0 +1,30 @@
1
+import { assert } from "@effect/vitest";
2
+import type { ProviderReplayTranscript } from "@t3tools/contracts";
3
+
4
+import type { OrchestratorV2ScenarioResult } from "../../OrchestratorScenario.ts";
5
+import {
6
+ assertAssistantTextIncludes,
7
+ assertBaseProjection,
8
+ assertSemanticProjectionIntegrity,
9
+ assertTurnItemTypes,
10
+ assertUserMessagesInclude,
11
+ projectionFor,
12
+} from "../shared.ts";
13
+import { MALFORMED_SESSION_UPDATE_PROMPT } from "./input.ts";
14
+
15
+export function assertMalformedSessionUpdateOutput(
16
+ result: OrchestratorV2ScenarioResult,
17
+ transcript: ProviderReplayTranscript,
18
+) {
19
+ assertBaseProjection({ result, transcript, runCount: 1, runStatuses: ["completed"] });
20
+ const projection = projectionFor(result, transcript.scenario);
21
+ assertSemanticProjectionIntegrity(projection);
22
+ assertUserMessagesInclude(projection, [MALFORMED_SESSION_UPDATE_PROMPT]);
23
+ assertTurnItemTypes(projection, ["user_message", "assistant_message"]);
24
+ // The dropped update does not fail the turn.
25
+ assert.notInclude(
26
+ projection.turnItems.map((item) => item.type),
27
+ "error",
28
+ );
29
+ assertAssistantTextIncludes(projection, "malformed update fixture ok");
30
+}
apps/server/src/orchestration-v2/testkit/fixtures/malformed_session_update/registry_transcript.ndjson
new
+14
@@ -0,0 +1,14 @@
1
+{"type":"transcript_start","provider":"acpRegistry","protocol":"acp.ndjson-jsonrpc","version":"1","scenario":"malformed_session_update","metadata":{"generatedBy":"protocol-semantic-fixture","nativeSessionId":"grok-replay-session-1"}}
2
+{"type":"expect_outbound","label":"initialize","frame":{"kind":"request","method":"initialize","params":{"protocolVersion":2,"info":"<any>","capabilities":"<any>","clientCapabilities":"<any>","clientInfo":"<any>"}}}
3
+{"type":"emit_inbound","label":"initialized","frame":{"kind":"response","method":"initialize","result":{"protocolVersion":1,"agentCapabilities":{"loadSession":true,"mcpCapabilities":{"http":true,"sse":true},"promptCapabilities":{"audio":false,"embeddedContext":true,"image":false}},"authMethods":[{"id":"replay","name":"Replay"}],"agentInfo":{"name":"grok-replay","version":"1"}}}}
4
+{"type":"expect_outbound","label":"session.new","frame":{"kind":"request","method":"session/new","params":{"cwd":"<workspace>","mcpServers":"<any>"}}}
5
+{"type":"emit_inbound","label":"session.created","frame":{"kind":"response","method":"session/new","result":{"sessionId":"grok-replay-session-1","models":{"currentModelId":"grok-build","availableModels":[{"modelId":"grok-build","name":"Grok Build"},{"modelId":"grok-composer-2.5-fast","name":"Grok Composer 2.5 Fast"}]}}}}
6
+{"type":"expect_outbound","label":"session.prompt","frame":{"kind":"request","method":"session/prompt","params":{"sessionId":"grok-replay-session-1","prompt":[{"type":"text","text":"<t3_code_instructions>\n<any>\n</t3_code_instructions>\n\n<user_request>\nRespond with the following text: malformed update fixture ok\n</user_request>"}]}}}
7
+{"type":"emit_inbound","label":"reasoning.1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"grok-replay-session-1","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":"I should "}}}}}
8
+{"type":"emit_inbound","label":"reasoning.2","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"grok-replay-session-1","update":{"sessionUpdate":"agent_thought_chunk","content":{"type":"text","text":"answer exactly."}}}}}
9
+{"type":"emit_inbound","label":"usage.malformed","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"grok-replay-session-1","update":{"sessionUpdate":"usage_update","cost":{"amount":0.01,"currency":"USD"}}}}}
10
+{"type":"emit_inbound","label":"assistant.1","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"grok-replay-session-1","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"malformed update "}}}}}
11
+{"type":"emit_inbound","label":"assistant.2","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"grok-replay-session-1","update":{"sessionUpdate":"agent_message_chunk","content":{"type":"text","text":"fixture ok"}}}}}
12
+{"type":"emit_inbound","label":"usage.valid","frame":{"kind":"notification","method":"session/update","params":{"sessionId":"grok-replay-session-1","update":{"sessionUpdate":"usage_update","used":1200,"size":200000}}}}
13
+{"type":"emit_inbound","label":"prompt.completed","frame":{"kind":"response","method":"session/prompt","result":{"stopReason":"end_turn"}}}
14
+{"type":"runtime_exit","status":"success"}
packages/effect-acp/src/errors.test.ts
+29
@@ -161,4 +161,33 @@ describe("effect-acp errors", () => {
161
expect("detail" in protocolError).toBe(false);
162
}),
163
);
164
+
165
+ // The summary goes into logs, so it names where a payload broke its schema
166
+ // and never copies a value, including a record key the agent chose.
167
+ it.effect("summarizes schema issues by path without payload values", () =>
168
+ Effect.gen(function* () {
169
+ const secret = "acp-summary-secret";
170
+ const cause = yield* Schema.decodeUnknownEffect(
171
+ Schema.Struct({
172
+ update: Schema.Struct({ used: Schema.Number, size: Schema.Number }),
173
+ env: Schema.Record(Schema.String, Schema.Number),
174
+ }),
175
+ )({ update: { size: secret }, env: { [`${secret} key`]: secret } }, { errors: "all" }).pipe(
176
+ Effect.flip,
177
+ );
178
+ const error = AcpError.AcpProtocolParseError.fromSchemaError(
179
+ "decode-notification-payload",
180
+ "session/update",
181
+ cause,
182
+ );
183
+
184
+ expect(error.issueSummary).toBe(
185
+ "update.used missing, update.size wrong type, env.* wrong type",
186
+ );
187
+ expect(error.message).toBe(
188
+ "ACP protocol operation 'decode-notification-payload' failed for method 'session/update': update.used missing, update.size wrong type, env.* wrong type.",
189
+ );
190
+ expect(error.message).not.toContain(secret);
191
+ }),
192
+ );
193
});
packages/effect-acp/src/errors.ts
+74
-1
@@ -1,4 +1,5 @@
1
import * as Schema from "effect/Schema";
2
+import * as SchemaAST from "effect/SchemaAST";
3
import type * as SchemaIssue from "effect/SchemaIssue";
4
5
import * as AcpSchema from "./_generated/schema.gen.ts";
@@ -37,6 +38,74 @@ interface AcpSchemaIssueDiagnostics {
38
readonly maximumPathDepth: number;
39
}
40
41
+const MAX_SUMMARY_ISSUES = 3;
42
+const MAX_SUMMARY_PATH_SEGMENTS = 8;
43
+
44
+// Record keys come from the payload, so a key that is not a plain identifier
45
+// is shown as `*` rather than copied.
46
+const summaryPathSegment = (segment: PropertyKey): string =>
47
+ typeof segment === "number" || /^[A-Za-z_][A-Za-z0-9_]{0,63}$/.test(String(segment))
48
+ ? String(segment)
49
+ : "*";
50
+
51
+const summaryPath = (path: ReadonlyArray<PropertyKey>): string => {
52
+ if (path.length === 0) return "payload";
53
+ const shown = path.slice(0, MAX_SUMMARY_PATH_SEGMENTS).map(summaryPathSegment).join(".");
54
+ return path.length > MAX_SUMMARY_PATH_SEGMENTS ? `${shown}…` : shown;
55
+};
56
+
57
+const summaryReason = (issue: SchemaIssue.Issue): string => {
58
+ switch (issue._tag) {
59
+ case "MissingKey":
60
+ return "missing";
61
+ case "UnexpectedKey":
62
+ return "unexpected";
63
+ case "InvalidType":
64
+ return "wrong type";
65
+ default:
66
+ return "invalid";
67
+ }
68
+};
69
+
70
+const isCatchAllMember = (issue: SchemaIssue.Issue) =>
71
+ "ast" in issue && SchemaAST.resolveTitle(issue.ast) === "other";
72
+
73
+/**
74
+ * Names where a payload broke its schema, such as `update.used missing`,
75
+ * without copying any value from it. ACP unions end in a member titled
76
+ * "other" that admits custom and future variants; it fails only because the
77
+ * discriminator names a known variant, so the known variant's issues are the
78
+ * ones reported.
79
+ */
80
+const schemaIssueSummary = (root: SchemaIssue.Issue): string => {
81
+ const entries = new Set<string>();
82
+ const visit = (issue: SchemaIssue.Issue, path: ReadonlyArray<PropertyKey>): void => {
83
+ switch (issue._tag) {
84
+ case "Filter":
85
+ case "Encoding":
86
+ visit(issue.issue, path);
87
+ return;
88
+ case "Pointer":
89
+ visit(issue.issue, [...path, ...issue.path]);
90
+ return;
91
+ case "Composite":
92
+ case "AnyOf": {
93
+ const known = issue.issues.filter((child) => !isCatchAllMember(child));
94
+ const children = known.length > 0 ? known : issue.issues;
95
+ if (children.length === 0) entries.add(`${summaryPath(path)} ${summaryReason(issue)}`);
96
+ for (const child of children) visit(child, path);
97
+ return;
98
+ }
99
+ default:
100
+ entries.add(`${summaryPath(path)} ${summaryReason(issue)}`);
101
+ }
102
+ };
103
+ visit(root, []);
104
+ const shown = [...entries].slice(0, MAX_SUMMARY_ISSUES);
105
+ const hidden = entries.size - shown.length;
106
+ return hidden > 0 ? `${shown.join(", ")} (+${hidden} more)` : shown.join(", ");
107
+};
108
+
109
const schemaIssueDiagnostics = (root: SchemaIssue.Issue): AcpSchemaIssueDiagnostics => {
110
let issueCount = 0;
111
let maximumPathDepth = 0;
@@ -123,12 +192,15 @@ export class AcpProtocolParseError extends Schema.TaggedError<AcpProtocolParseEr
192
issueCount: Schema.optionalKey(Schema.Number),
193
issueKinds: Schema.optionalKey(Schema.Array(AcpSchemaIssueKind)),
194
maximumPathDepth: Schema.optionalKey(Schema.Number),
195
+ /** Where the payload broke its schema, e.g. `update.used missing`; never payload values. */
196
+ issueSummary: Schema.optionalKey(Schema.String),
197
cause: Schema.Defect(),
198
},
199
) {
200
override get message() {
201
const method = this.method === undefined ? "" : ` for method '${this.method}'`;
131
- return `ACP protocol operation '${this.operation}' failed${method}.`;
202
+ const summary = this.issueSummary === undefined ? "" : `: ${this.issueSummary}`;
203
+ return `ACP protocol operation '${this.operation}' failed${method}${summary}.`;
204
}
205
206
static fromSchemaError(
@@ -140,6 +212,7 @@ export class AcpProtocolParseError extends Schema.TaggedError<AcpProtocolParseEr
212
operation,
213
method,
214
...schemaIssueDiagnostics(cause.issue),
215
+ issueSummary: schemaIssueSummary(cause.issue),
216
cause,
217
});
218
}
packages/effect-acp/src/protocol.test.ts
+93
-25
@@ -4,7 +4,9 @@ import * as Effect from "effect/Effect";
4
import * as Deferred from "effect/Deferred";
5
import * as Fiber from "effect/Fiber";
6
import * as Exit from "effect/Exit";
7
+import * as Logger from "effect/Logger";
8
import * as Queue from "effect/Queue";
9
+import * as References from "effect/References";
10
import * as Schema from "effect/Schema";
11
import * as Scope from "effect/Scope";
12
import * as Sink from "effect/Sink";
@@ -209,50 +211,116 @@ it.layer(NodeServices.layer)("effect-acp protocol", (it) => {
211
}),
212
);
213
212
- it.effect("keeps invalid core notification values only in the schema cause", () =>
214
+ // clanka once sent a usage_update without `used` and `size`. One bad update
215
+ // must not end a session whose later updates are fine.
216
+ it.effect("drops a session/update that fails to decode and keeps reading", () =>
217
Effect.gen(function* () {
218
const secret = "acp-core-notification-secret-sentinel";
219
const { stdio, input } = yield* makeInMemoryStdio();
216
- const termination = yield* Deferred.make<AcpError.AcpError>();
220
+ const events: Array<AcpProtocol.AcpProtocolLogEvent> = [];
221
+ const warnings: Array<unknown> = [];
222
+ let terminated = false;
223
let transformCalls = 0;
218
- yield* AcpProtocol.makeAcpPatchedProtocol({
224
+ const transport = yield* AcpProtocol.makeAcpPatchedProtocol({
225
stdio,
226
serverRequestMethods: new Set(),
227
+ logIncoming: true,
228
+ logger: (event) =>
229
+ Effect.sync(() => {
230
+ events.push(event);
231
+ }),
232
transformSessionUpdate: (notification) => {
233
transformCalls += 1;
234
return notification;
235
},
225
- onTermination: (error) => Deferred.succeed(termination, error).pipe(Effect.asVoid),
236
+ onTermination: () =>
237
+ Effect.sync(() => {
238
+ terminated = true;
239
+ }),
240
+ }).pipe(
241
+ Effect.provide(
242
+ Logger.layer([
243
+ Logger.make(({ logLevel, fiber }) => {
244
+ if (logLevel === "Warn")
245
+ warnings.push(fiber.getRef(References.CurrentLogAnnotations));
246
+ }),
247
+ ]),
248
+ ),
249
+ );
250
+ const received = yield* Deferred.make<AcpProtocol.AcpIncomingNotification>();
251
+ yield* transport.incoming.pipe(
252
+ Stream.runForEach((notification) => Deferred.succeed(received, notification)),
253
+ Effect.forkScoped,
254
+ );
255
+
256
+ const send = (params: unknown) =>
257
+ Queue.offer(
258
+ input,
259
+ encoder.encode(
260
+ `${encodeUnknownJsonString({ jsonrpc: "2.0", method: "session/update", params })}\n`,
261
+ ),
262
+ );
263
+ const malformed = {
264
+ sessionId: "session-1",
265
+ update: { sessionUpdate: "usage_update", cost: { amount: 1, currency: secret } },
266
+ };
267
+ yield* send(malformed);
268
+ yield* send(malformed);
269
+ yield* send({
270
+ sessionId: "session-1",
271
+ update: { sessionUpdate: "usage_update", used: 10, size: 100 },
272
});
273
228
- yield* Queue.offer(
229
- input,
230
- encoder.encode(
231
- `${encodeUnknownJsonString({
232
- jsonrpc: "2.0",
233
- method: "session/update",
234
- params: {
235
- sessionId: { secret },
236
- update: {
237
- sessionUpdate: "plan",
238
- entries: [],
239
- },
240
- },
241
- })}\n`,
242
- ),
274
+ const notification = yield* TestClock.withLive(
275
+ Deferred.await(received).pipe(Effect.timeout("2 seconds")),
276
);
277
+ assert.equal(notification._tag, "SessionUpdate");
278
+ assert.deepEqual(notification.params, {
279
+ sessionId: "session-1",
280
+ update: { sessionUpdate: "usage_update", used: 10, size: 100 },
281
+ });
282
+ assert.isFalse(terminated);
283
+ assert.equal(transformCalls, 1);
284
+
285
+ const decodeFailed = events.find(({ stage }) => stage === "decode_failed");
286
+ assert.deepInclude(decodeFailed?.payload as object, {
287
+ operation: "decode-notification-payload",
288
+ method: "session/update",
289
+ issueSummary: "update.used missing",
290
+ });
291
+ // The repeated bad update is dropped again but warned about once.
292
+ assert.lengthOf(
293
+ events.filter(({ stage }) => stage === "decode_failed"),
294
+ 2,
295
+ );
296
+ assert.lengthOf(warnings, 1);
297
+ assert.deepInclude(warnings[0] as object, {
298
+ issueSummary: "update.used missing",
299
+ });
300
+ assert.notInclude(encodeUnknownJsonString({ decodeFailed, warnings }), secret);
301
+ }),
302
+ );
303
245
- const error = yield* Deferred.await(termination);
246
- assert.equal(transformCalls, 0);
247
- assert.instanceOf(error, AcpError.AcpProtocolParseError);
248
- const parseError = error as AcpError.AcpProtocolParseError;
249
- const { cause, ...directDiagnostics } = parseError;
304
+ it.effect("keeps invalid core notification values only in the schema cause", () =>
305
+ Effect.gen(function* () {
306
+ const secret = "acp-core-notification-secret-sentinel";
307
+ const cause = yield* Schema.decodeUnknownEffect(AcpSchema.SessionNotification)({
308
+ sessionId: { secret },
309
+ update: { sessionUpdate: "plan", entries: [] },
310
+ }).pipe(Effect.flip);
311
+ const parseError = AcpError.AcpProtocolParseError.fromSchemaError(
312
+ "decode-notification-payload",
313
+ "session/update",
314
+ cause,
315
+ );
316
+ const { cause: directCause, ...directDiagnostics } = parseError;
317
assert.equal(parseError.operation, "decode-notification-payload");
318
assert.equal(parseError.method, "session/update");
319
assert.isAbove(parseError.issueCount ?? 0, 0);
320
assert.include(parseError.issueKinds ?? [], "Pointer");
321
assert.isAbove(parseError.maximumPathDepth ?? 0, 0);
255
- assert.isTrue(Schema.isSchemaError(cause));
322
+ assert.equal(parseError.issueSummary, "sessionId wrong type");
323
+ assert.isTrue(Schema.isSchemaError(directCause));
324
assert.notInclude(parseError.message, secret);
325
assert.notInclude(encodeUnknownJsonString(directDiagnostics), secret);
326
}),
packages/effect-acp/src/protocol.ts
+54
-39
@@ -166,6 +166,17 @@ const makeStrictNdJsonRpcParser = () => {
166
};
167
};
168
const MAX_BUFFERED_RAW_NOTIFICATIONS = 32;
169
+
170
+/** A decode failure's structural diagnostics, without its cause or any wire payload. */
171
+const decodeFailureDiagnostics = (error: AcpError.AcpProtocolParseError) => ({
172
+ operation: error.operation,
173
+ ...(error.method === undefined ? {} : { method: error.method }),
174
+ ...(error.requestId === undefined ? {} : { requestId: error.requestId }),
175
+ ...(error.issueCount === undefined ? {} : { issueCount: error.issueCount }),
176
+ ...(error.issueKinds === undefined ? {} : { issueKinds: error.issueKinds }),
177
+ ...(error.maximumPathDepth === undefined ? {} : { maximumPathDepth: error.maximumPathDepth }),
178
+ ...(error.issueSummary === undefined ? {} : { issueSummary: error.issueSummary }),
179
+});
180
// Outbound JSON-RPC notification: no `id`, so peers never treat it as a request.
181
const encodeJsonRpcNotification = Schema.encodeUnknownExit(
182
Schema.fromJsonString(
@@ -223,6 +234,7 @@ export const makeAcpPatchedProtocol = Effect.fn("makeAcpPatchedProtocol")(functi
234
outstandingAcknowledgements: new Set(),
235
});
236
const nextRequestId = yield* Ref.make(1);
237
+ const warnedDecodeFailures = new Set<string>();
238
const terminationHandled = yield* Ref.make(false);
239
const terminationFailure = yield* Deferred.make<never, AcpError.AcpError>();
240
const extPending = yield* Ref.make(new Map<string, AcpPendingRequest>());
@@ -499,26 +511,49 @@ export const makeAcpPatchedProtocol = Effect.fn("makeAcpPatchedProtocol")(functi
511
);
512
};
513
514
+ // A notification has no reply to fail, so one the schema rejects is logged
515
+ // and dropped. Ending the connection over it would kill a working session
516
+ // because one update, possibly from a newer spec, did not parse. An agent
517
+ // repeats a bad shape on every update, so each distinct failure is warned
518
+ // about once per connection.
519
+ const dropUndecodableNotification = (method: string) => (cause: Schema.SchemaError) => {
520
+ const error = AcpError.AcpProtocolParseError.fromSchemaError(
521
+ "decode-notification-payload",
522
+ method,
523
+ cause,
524
+ );
525
+ const diagnostics = decodeFailureDiagnostics(error);
526
+ const key = `${method}\n${error.issueSummary}`;
527
+ const firstOfItsKind = !warnedDecodeFailures.has(key);
528
+ warnedDecodeFailures.add(key);
529
+ return logProtocol({
530
+ direction: "incoming",
531
+ stage: "decode_failed",
532
+ payload: diagnostics,
533
+ }).pipe(
534
+ Effect.andThen(
535
+ firstOfItsKind
536
+ ? Effect.logWarning("Dropped an ACP notification that failed to decode").pipe(
537
+ Effect.annotateLogs(diagnostics),
538
+ )
539
+ : Effect.void,
540
+ ),
541
+ );
542
+ };
543
+
544
const handleRequestEncoded = (message: RpcMessage.RequestEncoded) => {
545
if (message.id === "") {
546
if (message.tag === CLIENT_METHODS.session_update) {
547
return decodeSessionUpdate(message.payload).pipe(
506
- Effect.map(
507
- (params) =>
508
- ({
548
+ Effect.matchEffect({
549
+ onFailure: dropUndecodableNotification(CLIENT_METHODS.session_update),
550
+ onSuccess: (params) =>
551
+ dispatchNotification({
552
_tag: "SessionUpdate",
553
method: CLIENT_METHODS.session_update,
554
params: options.transformSessionUpdate?.(params) ?? params,
512
- }) satisfies AcpIncomingNotification,
513
- ),
514
- Effect.mapError((cause) =>
515
- AcpError.AcpProtocolParseError.fromSchemaError(
516
- "decode-notification-payload",
517
- CLIENT_METHODS.session_update,
518
- cause,
519
- ),
520
- ),
521
- Effect.flatMap(dispatchNotification),
555
+ }),
556
+ }),
557
);
558
}
559
if (
@@ -527,22 +562,11 @@ export const makeAcpPatchedProtocol = Effect.fn("makeAcpPatchedProtocol")(functi
562
) {
563
const method = message.tag;
564
return decodeElicitationComplete(message.payload).pipe(
530
- Effect.map(
531
- (params) =>
532
- ({
533
- _tag: "ElicitationComplete",
534
- method,
535
- params,
536
- }) satisfies AcpIncomingNotification,
537
- ),
538
- Effect.mapError((cause) =>
539
- AcpError.AcpProtocolParseError.fromSchemaError(
540
- "decode-notification-payload",
541
- method,
542
- cause,
543
- ),
544
- ),
545
- Effect.flatMap(dispatchNotification),
565
+ Effect.matchEffect({
566
+ onFailure: dropUndecodableNotification(method),
567
+ onSuccess: (params) =>
568
+ dispatchNotification({ _tag: "ElicitationComplete", method, params }),
569
+ }),
570
);
571
}
572
return dispatchNotification({
@@ -696,16 +720,7 @@ export const makeAcpPatchedProtocol = Effect.fn("makeAcpPatchedProtocol")(functi
720
logProtocol({
721
direction: "incoming",
722
stage: "decode_failed",
699
- payload: {
700
- operation: error.operation,
701
- ...(error.method === undefined ? {} : { method: error.method }),
702
- ...(error.requestId === undefined ? {} : { requestId: error.requestId }),
703
- ...(error.issueCount === undefined ? {} : { issueCount: error.issueCount }),
704
- ...(error.issueKinds === undefined ? {} : { issueKinds: error.issueKinds }),
705
- ...(error.maximumPathDepth === undefined
706
- ? {}
707
- : { maximumPathDepth: error.maximumPathDepth }),
708
- },
723
+ payload: decodeFailureDiagnostics(error),
724
}),
725
),
726
Effect.flatMap((messages) =>