You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: How to keep link between request and response in a multiplexed condition #324
I am implementing a client that is a server side application and I am at a loss to keep connected my request from the response.
First question: is it expected that clients can multiplex requests to a given server? Or is it expected to create separate client instances for separate work?
I think multiplexing is expected:
see the spec "6.11.1. JSONRPCRequest Object" which mandates the id parameter to be filled for element expecting request / response. That seems JSONRPC specific and unfortunately is not exposed by the A2A Java SDK
I can't use messageId unless history is enabled but that's an optional feature.
I can't use contextId technically because the server is suppose to give a new contextId upon first request.
The SDK does not have a form of continuation, it has listeners that react to events but no a priori link to the request message that initiated that response.
I think something is missing either at the spec level or at the Java SDK level.
My use case is that I have a multiplexed server side A2A client that can have several customers interacting with the server. So either id should be exposed (but what about gRPC and REST) or some form of informational continuation is expected like originatingMessageId of some form. Maybe contextId could work but it does not address the use case of parallel work within a context id. Expecting sequential request / response seems inadequate.
Hi, I've tried to parse your question, but am not sure I understand what you mean.
I'll try to outline what happens.
Each request is associated with a Task, which is built up with the streaming and non-streaming sendMessage() calls. On the first sendMessage() you generally use no id for the task, an id is then generated and a new Task is created on the server. The Task object is kind of the main memory/context for what is being worked on (e.g. "book me a flight somewhere cheap and sunny in November").
Then the response contains the Task that was created (or a Message for something super simple). Those will have the generated task id set.
It the task is not complete, you can then send more messages to it with the task id set in the request, and responses for that request, whether streaming/non-streaming, will be for that task.
If you want to work on other Tasks, you need other requests.
If that is not possible, and you need a new client for each task then that is a bug.
If you mean something else, please let us know :-)
So user 1 , user 2 and user 3 send each a message request and all message responses will come to the listener is an indiscriminate fashion, I need a way to associate a response to a given user (to a given request really).
How do I do that?
We can forget about tasks and only focus on Message in, message out.
If the answer is that for a given Client instance you need to message response (or task submitted) to come back before being able to send a new message request, then the client is not able to treat parallel requests at scale and we are back into the horrifying kluge that DB connection pooling is. And I think think we want that :)
Ah I did not realise that sendMessage was overloaded and that one version allows to pass per message consumers. I think that would allow to isolate user 1, user 2 etc from one another? At least at the API level, is it true at the protocol level?
Hi, @fjuma is away until next week and I'm not intimately familiar with the client. But I'll try to answer a bit anyway.
The Client is a layer on top of what the spec does. The actual 'spec' implementations are these ones JSONRPCTransport, GrpcTransport and RestTransport. As you can see they are quite different, so we decided to unify them into one thing quite recently.
The Client delegates to these under the hood. So there is some scope to do more things there if needed.
However, each method on the Client ends up with one underlying HTTP request. For non-streaming, that is a normal HTTP request. For the streaming varieties, the returned data is via SSE.
So if user1 calls sendMessage() and user2 calls sendMessage() what happens to those should be totally separate. Is this the separation you are looking for?
Of course, if they both work on the same Task and subscribe to streaming events, they will see each other's data. But, as a Task is logically something associated with what a user wants to do, I don't think that is something that should happen in practice. (Tangent: I realise writing this that there is nothing stopping user1 to work on Task A, and user2 to also work on Task A. That might be something we should look into.)
If I am still not understanding what you are asking, let me know!
So if user1 calls sendMessage() and user2 calls sendMessage() what happens to those should be totally separate. Is this the > separation you are looking for?
Right.
To handle the responses received by the client, you can either configure Client-wide consumers or specify them per sendMessage() call.
For the Message case, it's one just response, there'll be no further messages after that for that sendMessage request.
For the streaming case, you get back a Task that has an id that can be referenced later on.
contextId can group together multiple Tasks and Messages.
What I have notice though is the fact that A2A inspector does not support multi-turn conversation, I mean, I does not have currently an option to send the taskid from the previous response message received from the server agent so I was having to test my scenarios using client agent Java classes which is not ideal. It would have been easier if I could input/inject into my message any taskid in the A2A inspector somehow
Activity
kabir commentedon Oct 2, 2025
Hi, I've tried to parse your question, but am not sure I understand what you mean.
I'll try to outline what happens.
Each request is associated with a Task, which is built up with the streaming and non-streaming sendMessage() calls. On the first sendMessage() you generally use no id for the task, an id is then generated and a new Task is created on the server. The Task object is kind of the main memory/context for what is being worked on (e.g. "book me a flight somewhere cheap and sunny in November").
Then the response contains the Task that was created (or a Message for something super simple). Those will have the generated task id set.
It the task is not complete, you can then send more messages to it with the task id set in the request, and responses for that request, whether streaming/non-streaming, will be for that task.
If you want to work on other Tasks, you need other requests.
If that is not possible, and you need a new client for each task then that is a bug.
If you mean something else, please let us know :-)
emmanuelbernard commentedon Oct 2, 2025
Hey there,
Let me try and add some context.
Let's assume a client written like this one https://github.com/a2aproject/a2a-samples/blob/main/samples/java/agents/dice_agent_multi_transport/client/src/main/java/com/samples/a2a/client/TestClient.java#L124 but not for CLIs, for say an app server.
So the number of parallel request from different users and context is a requirement.
The way you set a way to react to the response is via some form of listener
https://github.com/a2aproject/a2a-samples/blob/main/samples/java/agents/dice_agent_multi_transport/client/src/main/java/com/samples/a2a/client/TestClient.java#L156
So user 1 , user 2 and user 3 send each a message request and all message responses will come to the listener is an indiscriminate fashion, I need a way to associate a response to a given user (to a given request really).
How do I do that?
We can forget about tasks and only focus on Message in, message out.
If the answer is that for a given
Clientinstance you need to message response (or task submitted) to come back before being able to send a new message request, then the client is not able to treat parallel requests at scale and we are back into the horrifying kluge that DB connection pooling is. And I think think we want that :)emmanuelbernard commentedon Oct 3, 2025
Ah I did not realise that
sendMessagewas overloaded and that one version allows to pass per message consumers. I think that would allow to isolate user 1, user 2 etc from one another? At least at the API level, is it true at the protocol level?kabir commentedon Oct 3, 2025
Hi, @fjuma is away until next week and I'm not intimately familiar with the client. But I'll try to answer a bit anyway.
The Client is a layer on top of what the spec does. The actual 'spec' implementations are these ones JSONRPCTransport, GrpcTransport and RestTransport. As you can see they are quite different, so we decided to unify them into one thing quite recently.
The Client delegates to these under the hood. So there is some scope to do more things there if needed.
However, each method on the Client ends up with one underlying HTTP request. For non-streaming, that is a normal HTTP request. For the streaming varieties, the returned data is via SSE.
So if user1 calls
sendMessage()and user2 callssendMessage()what happens to those should be totally separate. Is this the separation you are looking for?Of course, if they both work on the same Task and subscribe to streaming events, they will see each other's data. But, as a Task is logically something associated with what a user wants to do, I don't think that is something that should happen in practice. (Tangent: I realise writing this that there is nothing stopping user1 to work on Task A, and user2 to also work on Task A. That might be something we should look into.)
If I am still not understanding what you are asking, let me know!
kabir commentedon Oct 3, 2025
Actually, the current incarnation of GrpcTransport isn't as different as the original. Earlier we had a very different interface there
fjuma commentedon Oct 6, 2025
Right.
To handle the responses received by the client, you can either configure Client-wide consumers or specify them per
sendMessage()call.For the
Messagecase, it's one just response, there'll be no further messages after that for thatsendMessagerequest.For the streaming case, you get back a
Taskthat has an id that can be referenced later on.contextIdcan group together multipleTasksandMessages.mescaja commentedon Dec 19, 2025
I have runs few scenarios with 2 a2a client agent and one server agent
First client agent runs, send a message and get a request_input response message from the server agent. Then it resubscribes to the task updates.
At this point I open a second console and run the second client agent which sends a message passing the same context if and taskid
Thr server agent calls an MCP server, create an artefact with the response from the MCP request and close the task
At this point the first client agent received the artefact and final message
This demonstrate that multiple, client and server agents can send messages and receive updates in relation to the same task
mescaja commentedon Dec 19, 2025
So I can’t see any bugs as far as I am concerned
What I have notice though is the fact that A2A inspector does not support multi-turn conversation, I mean, I does not have currently an option to send the taskid from the previous response message received from the server agent so I was having to test my scenarios using client agent Java classes which is not ideal. It would have been easier if I could input/inject into my message any taskid in the A2A inspector somehow
kabir commentedon Feb 6, 2026
Closing, since I think this was more of a question