Skip to content

Conversation

@Nemtecl
Copy link

@Nemtecl Nemtecl commented Nov 17, 2025

This document proposes the addition of a messageId field so that we can identify user and assistant message

@Nemtecl Nemtecl requested a review from a team as a code owner November 17, 2025 17:26
@Nemtecl Nemtecl changed the title RFD: introduce `messageId field RFD: introduce messageId field Nov 17, 2025

The **Agent generates all message IDs**, for both user and agent messages:

- **For user messages**: When the Client sends `session/prompt`, the Agent assigns a message ID and returns it as `messageId` in the response
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But a response to the session/prompt comes only after all session\update messages are streamed https://agentclientprotocol.com/protocol/prompt-turn . We also plan to support user messages in the middle of the agent's interactions, in this case it's also not clear how to return messageId to the client.
I like your proposal a lot, but this particular part about server generating client messages' ids looks a little cumbersome to me

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. An alternate approach could be to introduce a new session/update that assigns it... But I wonder if we just need a way to get unique ids from both sides.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Strictly speaking, you want them to be unique only among client\server messages. A message role (user/assistant) can be treated as a part of the id, but this complicates things in the scenario with multiple clients. But probably we can be safe just having UUIDs there, wdyt?

Copy link
Member

@benbrandt benbrandt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice start! I have a few comments, but I think this is definitely a much needed feature


## What we propose to do about it

Add a `messageId` field to `AgentMessageChunk` and `UserMessageChunk` session updates, and to the `session/prompt` response. This field would:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @anna239 here... I am unclear on why a session/prompt response would need a messageId?

If anything that would feel more like a "turnId" which I'm not sure if that would always hold up either.

Basically a prompt would create one or more "messages" , which would happen via the chunks, and then I don't think we need anything on the prompt, unless I am missing something.

We could introduce a new session/update type of "message start" and "message end" if needed to carry extra metadata... but I am not sure how useful that is and would hold off unless we have a strong reason to do it.

I think as proposed this ultimately has similar behavior to now (you have to watch the chunks for a new message id) but does allow you to split messages of the same type, which is useful.

And it creates a nice anchor for other features as you mentioned

- **Unique per message** within a session
- **Stable across chunks** - all chunks belonging to the same message share the same `messageId`
- **Opaque** - Clients treat it as an identifier without parsing its structure
- **Agent-generated** - The Agent generates and manages all message IDs, consistent with how the protocol handles `sessionId`, `terminalId`, and `toolCallId`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do we handle messageIds for user messages? Are they generated by the client?
The agent is also allowed to supply user messages, it is true, but I feel we need to also allow the user messages from the prompt to have an id as well

If we allow both sides to generate though, we may need to require something like a uuid or have a prefix or something to avoid collisions

### Phase 1: Core Protocol Changes

1. **Update schema** (`schema/schema.json`):
- Add required `messageId` field (type: `string`) to `AgentMessageChunk`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this a non-breaking change, we will need to have this be optional for now.
We can add SHOULD language to the spec, but changing that to a MUST/required will need to be a v2 change


Alternatively, the field could initially be made **optional** to allow gradual adoption:

- Agents that support it advertise a capability flag during initialization
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can do optional, and then features that require a messageId would have an implicit flag in the sense that those methods would require a messageId and you wouldn't have one


The **Agent generates all message IDs**, for both user and agent messages:

- **For user messages**: When the Client sends `session/prompt`, the Agent assigns a message ID and returns it as `messageId` in the response
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. An alternate approach could be to introduce a new session/update that assigns it... But I wonder if we just need a way to get unique ids from both sides.


- Tool calls use `toolCallId`
- Plan entries can be tracked by their position in the `entries` array
- Agent thoughts could benefit from message IDs if they're considered distinct messages
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason not to add it to thoughts now? Wouldn't you also want some distinction there?

And could one message contain two tool calls?

I guess I am realizing it would make sense to better define what a "message" is in the protocol, and that might better guide which things need or don't need a message id

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants