Skip to content

[Bug]: How to keep link between request and response in a multiplexed condition #324

Closed

Description

@emmanuelbernard

What happened?

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:

But when you look at the spec workflows, there is no way to link the message request with the task return or message return https://a2a-protocol.org/latest/specification/#9-common-workflows-examples excpt via the id field which is not exposed.

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.

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. kabir commented on Oct 2, 2025

    @kabir
    Collaborator

    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 :-)

  2. emmanuelbernard commented on Oct 2, 2025

    @emmanuelbernard
    Author

    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 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 :)

  3. emmanuelbernard commented on Oct 3, 2025

    @emmanuelbernard
    Author

    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?

  4. kabir commented on Oct 3, 2025

    @kabir
    Collaborator

    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!

  5. kabir commented on Oct 3, 2025

    @kabir
    Collaborator

    Actually, the current incarnation of GrpcTransport isn't as different as the original. Earlier we had a very different interface there

  6. fjuma commented on Oct 6, 2025

    @fjuma
    Contributor

    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.

  7. mescaja commented on Dec 19, 2025

    @mescaja

    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

  8. mescaja commented on Dec 19, 2025

    @mescaja

    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

  9. added
    wontfix
    on Feb 6, 2026
  10. kabir commented on Feb 6, 2026

    @kabir
    Collaborator

    Closing, since I think this was more of a question

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfix

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions