From 0d54a797162774b08d1a3324f70bd41c97bcae1e Mon Sep 17 00:00:00 2001 From: steve02081504 Date: Sun, 1 Mar 2026 20:13:18 +0800 Subject: [PATCH] add `agent_message_clear` impls https://github.com/agentclientprotocol/agent-client-protocol/pull/465 --- schema/schema.json | 11 +++++++++++ src/examples/client.ts | 4 ++++ src/schema/index.ts | 1 + src/schema/types.gen.ts | 3 +++ src/schema/zod.gen.ts | 3 +++ 5 files changed, 22 insertions(+) diff --git a/schema/schema.json b/schema/schema.json index f6bed4a..7891f5f 100644 --- a/schema/schema.json +++ b/schema/schema.json @@ -3091,6 +3091,17 @@ "required": ["sessionUpdate"], "type": "object" }, + { + "description": "Instructs the client to clear the accumulated streamed content for the current agent message. Subsequent agent_message_chunk updates append from empty. Enables non-monotonic streaming (e.g. reformatting, delegation, iterative refinement).", + "properties": { + "sessionUpdate": { + "const": "agent_message_clear", + "type": "string" + } + }, + "required": ["sessionUpdate"], + "type": "object" + }, { "allOf": [ { diff --git a/src/examples/client.ts b/src/examples/client.ts index d4418e9..db2268d 100644 --- a/src/examples/client.ts +++ b/src/examples/client.ts @@ -53,6 +53,10 @@ class ExampleClient implements acp.Client { console.log(`[${update.content.type}]`); } break; + case "agent_message_clear": + // Client should clear accumulated streamed content for current agent message. + console.log(`[${update.sessionUpdate}]`); + break; case "tool_call": console.log(`\n🔧 ${update.title} (${update.status})`); break; diff --git a/src/schema/index.ts b/src/schema/index.ts index 958bc84..6b18f1d 100644 --- a/src/schema/index.ts +++ b/src/schema/index.ts @@ -18,6 +18,7 @@ export type { CancelRequestNotification, ClientCapabilities, ClientNotification, + ClientOptions, ClientRequest, ClientResponse, ConfigOptionUpdate, diff --git a/src/schema/types.gen.ts b/src/schema/types.gen.ts index b6104f4..5037b1c 100644 --- a/src/schema/types.gen.ts +++ b/src/schema/types.gen.ts @@ -2434,6 +2434,9 @@ export type SessionUpdate = | (ContentChunk & { sessionUpdate: "agent_message_chunk"; }) + | { + sessionUpdate: "agent_message_clear"; + } | (ContentChunk & { sessionUpdate: "agent_thought_chunk"; }) diff --git a/src/schema/zod.gen.ts b/src/schema/zod.gen.ts index 055de7e..8be8e1d 100644 --- a/src/schema/zod.gen.ts +++ b/src/schema/zod.gen.ts @@ -1580,6 +1580,9 @@ export const zSessionUpdate = z.union([ sessionUpdate: z.literal("agent_message_chunk"), }), ), + z.object({ + sessionUpdate: z.literal("agent_message_clear"), + }), zContentChunk.and( z.object({ sessionUpdate: z.literal("agent_thought_chunk"),