new RFD: Create agent_message_clear.md#465
new RFD: Create agent_message_clear.md#465steve02081504 wants to merge 7 commits intoagentclientprotocol:mainfrom
Conversation
work with agentclientprotocol/rust-sdk#59 , impls agentclientprotocol#465
benbrandt
left a comment
There was a problem hiding this comment.
I feel like this should build on top of the new message ids so we know which to clear.
Another option would be to allow for agent_message in addition to agent_message_chunk with an id and if we see a full message with an existing id it would replace all previous chunks/text for that id, similar to tool calls.
thoughts?
I don't think the existing ACP spec has the concept of message IDs yet — currently a single stdio link can only correspond to one agent session, so messages are inherently unique. |
|
The spec already supports multiple sessions on the same connection. In fact we are now using this in Zed, and all of the agents as far as I know support it. You can call session/new multiple times and all notifications + session related methods require a session id |
coool, good to know :D |
Elevator pitch
The current Agent Communication Protocol (ACP) treats
agent_message_chunkas a strictly append-only operation. This proposal introduces a new session update type,agent_message_clear, which allows agents to clear the accumulated streamed content. This enables support for non-monotonic streaming scenarios—such as iterative refinement, post-processing, and speculative decoding—without causing UI clutter or redundant message history.Status quo
Currently, the
agent_message_chunksession update is strictly cumulative. The client concatenates all received chunks into the agent's message with no mechanism to clear or replace what has already been streamed. This is problematic for agents where content generation is non-monotonic:Current Workarounds:
---) and re-send the entire text. This causes UI clutter, flicker, and massive context waste in transcripts.What we propose to do about it
We propose adding a new session update type:
agent_message_clear.This update instructs the client to immediately clear the accumulated streamed content for the current agent message in the given session. Subsequent
agent_message_chunkupdates will then start appending from an empty state. (The ACP spec already supports multiple sessions on the same connection via repeatedsession/new; all session-scoped notifications and methods carry asessionId, so "current" is unambiguous per session.)Key characteristics:
planupdates andtool_call_updatecontent.SessionUpdatevariant without changing existing logic.Shiny future
In the shiny future, agent UIs will be fluid and reactive.
fount) can push full-state updates safely, knowing the protocol handles the "reset" efficiently.Implementation details and plan
Protocol Change
Add
agent_message_clearto theSessionUpdatevariant list. When message IDs are in use (unstable today), the update may include an optionalmessageIdto clear a specific message; otherwise it clears the current message in the session.JSON-RPC Example (clear current message):
{ "jsonrpc": "2.0", "method": "session/update", "params": { "sessionId": "sess_abc123", "update": { "sessionUpdate": "agent_message_clear" } } }With optional
messageId(when message ID is supported):{ "jsonrpc": "2.0", "method": "session/update", "params": { "sessionId": "sess_abc123", "update": { "sessionUpdate": "agent_message_clear", "messageId": "msg_uuid_here" } } }Usage Pattern
agent_message_chunkwith text "Drafting...".agent_message_clear.agent_message_chunkwith the final, polished content.Implementation Plan
agent_message_clear.agent_thought_clearif agents require similar non-monotonic behavior for internal reasoning blocks.Frequently asked questions
What alternative approaches did you consider, and why did you settle on this one?
Several designs were evaluated:
agent_message_replacereplace: trueflagagent_message_clearwas chosen because it is the most consistent with existing ACP patterns (likeplanupdates) and provides the best balance between implementation simplicity and functional power.How does this affect backward compatibility?
It is fully backward-compatible. A legacy client will simply ignore the unknown
agent_message_clearnotification. The result is that the user sees the old text and new text concatenated, which is identical to the current "Separator" workaround.Does this replace the entire message history?
No. It only clears the "accumulated streamed content" of the current active agent message in the session. It does not affect previously finalized messages in the chat history.
What about message IDs and "replace by id"?
The spec already has message IDs (currently unstable):
agent_message_chunkand related updates can carry an optionalmessageId; see the Message ID RFD andschema.unstable.json. Review feedback suggested building on this so we know which message to clear, and an alternative design: allowagent_message(full message) in addition toagent_message_chunk, with anid—when the client sees a full message with an existing id, it would replace all previous chunks/text for that id, similar to tool call updates.This RFD should align with that existing mechanism:
agent_message_clearcan take an optionalmessageId; when present, the client clears the accumulated content for that message id; when absent, it clears the "current" message (same as today's implicit semantics). That way we build on top of the new message ids as suggested. The "fullagent_messagewith id for replace" design remains a viable alternative or future extension.Revision history
messageIdonagent_message_clear; replace-by-id alternative noted.