adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

Duplicated/wrong events when using A2A agent in streaming mode

Open seandi opened this issue 1 year ago • 3 comments

Describe the bug As of v1.16.0 when using a remote A2A agent in streaming mode, the client agent receives some duplicated events (see screenshot below). In particular:

  1. The client agent receives an event from the server with the message that was sent with the A2A request. This is particularly annoying since the A2A request is constructed to include all previous events up to the last event from the remote agent, so the client will see in subsequent turns the same event/s twice and from different authors.
  2. The last event from the remote agent is returned twice, once from the actual ADK event in the remote agent and once from the TaskArtifactUpdateEvent issued by the A2aAgentExecutor which contains as artifact the last message from the remote agent (if the agent completed its invocation regularly)

To Reproduce

  1. Modify the basic a2a sample from contributing/samples/a2a_root to enable streaming
  2. Change the server to expose streaming support by modifying the agent card in the to_app function used in the contributing/samples/a2a_root/remote_a2a/hello_world/agent.py as follows:
      card_builder = AgentCardBuilder(
          agent=agent,
          rpc_url=rpc_url,
          capabilities=AgentCapabilities(
              streaming=True,
          ),
      )
  1. change the client to request streaming responses by modifying the contributing/samples/a2a_root/agent.py:
  from a2a.client.client import ClientConfig as A2AClientConfig
  from a2a.client.client_factory import ClientFactory as A2AClientFactory
  from a2a.types import TransportProtocol as A2ATransport
  from google.adk.agents.remote_a2a_agent import AGENT_CARD_WELL_KNOWN_PATH
  from google.adk.agents.remote_a2a_agent import RemoteA2aAgent
  
  # Configure the client factory to support streaming
  client_config = A2AClientConfig(
      streaming=True,
      polling=False,
      supported_transports=[A2ATransport.jsonrpc],
  )
  a2a_client_factory = A2AClientFactory(config=client_config)
  
  
  root_agent = RemoteA2aAgent(
      name="hello_world_agent",
      description=(
          "Helpful assistant that can roll dice and check if numbers are prime."
      ),
      agent_card=f"http://localhost:8001/{AGENT_CARD_WELL_KNOWN_PATH}",
      a2a_client_factory=a2a_client_factory,
  )
  1. Run client and server as described here
  2. Do a simple test

Expected behavior The a2a request should not appear as an event authored by the remote agent, and a single event should be generated for the agent final response.

Screenshots Here we can see that the a2a request is mirrored as a server generated event, and that we have two events for the final answer:

Image

Possible solution: These could be a potential way to address the behaviour reported above:

  1. Do not include the request message when updating the task status to submitted in A2aAgentExecutor.execute
  2. Do not send the TaskArtifactUpdateEvent after the agent is done in A2aAgentExecutor._handle_request. And possibly avoid including the message in the TaskStatusUpdateEvent in case the agent has failed or required user input.

Desktop:

  • OS: Linux
  • Python version(python -V): 3.11
  • ADK version(pip show google-adk): 1.16.0

Model Information:

  • Are you using LiteLLM: Yes
  • Model used: gpt-4.1

seandi avatar Oct 17 '25 13:10 seandi

Hello @seandi ,

We recommend testing with the latest version of google-adk. If you still encounter the issue after updating, please share a screenshot of the request and response for all events. This will help us analyze the issue more effectively.

llalitkumarrr avatar Dec 02 '25 13:12 llalitkumarrr

This issue has been automatically marked as stale because it has not had recent activity for 7 days after a maintainer requested clarification. It will be closed if no further activity occurs within 7 days.

adk-bot avatar Dec 10 '25 05:12 adk-bot

This has been automatically closed because it has been marked as stale for over 7 days.

adk-bot avatar Dec 18 '25 23:12 adk-bot