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

[BUG] A2A Doesn't Support Data Types

Open blakeromano opened this issue 1 year ago • 7 comments

Checks

  • [x] I have updated to the lastest minor and patch version of Strands
  • [x] I have checked the documentation and this is not expected behavior
  • [x] I have searched ./issues and there are no duplicates of my issue

Strands Version

1.0.0

Python Version

3.13

Operating System

macOS 15.5

Installation Method

pip

Steps to Reproduce

Have an invoke command for the A2A Server like so:

import asyncio
import json
import httpx
from uuid import uuid4
from a2a.client import A2ACardResolver, A2AClient
from a2a.types import MessageSendParams, SendStreamingMessageRequest, SendMessageRequest

async def ask_agent(port: str):
  async with httpx.AsyncClient(timeout=httpx.Timeout(timeout=None)) as httpx_client:
    # Connect to the agent
    resolver = A2ACardResolver(httpx_client=httpx_client, base_url="http://localhost/:" + port)

    agent_card = await resolver.get_agent_card()
    print("Agent:", agent_card.name)
    client = A2AClient(httpx_client=httpx_client, agent_card=agent_card)
    message = input("Enter your message: ")

    # Send the message
    request = SendMessageRequest(
      id=str(uuid4()),
      params=MessageSendParams(
        message={
          "role": "user",
          "parts": [{"kind":"data", "data": {"text": "User's favorite villain is the Joker"}}, {"kind": "text", "text": message}],
          "messageId": uuid4().hex,
        }
      ),
    )
    
    response = await client.send_message(request)
    print("Response:", response.model_dump(mode="json", exclude_none=True))


# Example usage
async def main():
  port = input("Enter the port of your agent: ")
  await ask_agent(port)



if __name__ == "__main__":
  asyncio.run(main())

Create an A2A Server like so:

import logging
import sys

from strands import Agent
from strands.multiagent.a2a import A2AServer
from strands.models.bedrock import BedrockModel

logging.basicConfig(
  level=logging.ERROR,
  format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
  handlers=[logging.StreamHandler(sys.stdout)],
  force=True,
)

# Log that we're starting
logging.info("Starting A2A server with root logger")

strands_agent = Agent(
  name= "Hello World Agent",
  model= BedrockModel(
    region_name="us-west-2",
    model_id="us.anthropic.claude-3-7-sonnet-20250219-v1:0",
    streaming=True,
  ),
  description="Just a hello world agent",
)

# uncomment to enable streaming
# strands_a2a_agent = A2AServer(agent=strands_agent, streaming=True)

# sync enabled
strands_a2a_agent = A2AServer(agent=strands_agent)

strands_a2a_agent.serve()

When invoking the Bedrock Converse API it doesn't seem to actually pass along the DataPart type (even though data part is just an arbitrary object of string keys and values of any type).

Expected Behavior

I would expect A2A Servers to pass along DataParts to the Converse API https://a2a-protocol.org/latest/specification/#653-datapart-object as defined in the specification.

Actual Behavior

DataParts are not forwarded when invoking the LLM.

Additional Context

As noted in this issue here https://github.com/a2aproject/A2A/issues/602 we are trying to use DataParts to pass context from previous messages in the session (previous messages between the agent and the user) to bring context which as noted in the comments in this issue folks seem to either do this via a DataPart or by using metadata.

Possible Solution

No response

Related Issues

No response

blakeromano avatar Jul 23 '25 15:07 blakeromano

hi @blakeromano thank you for your submission.!

As per the A2A spec for DataPart:

For conveying structured JSON data. Useful for forms, parameters, or any machine-readable information.

Which seems more akin to a structured output use case than the default type for model responses.

Can you provide some additional context on your use case and why this needs to specifically be a DataPart and not a Message? Another reason I ask is because the underlying Strands agent behind the A2AServer already manages conversation history for you and the underlying format is an internal representation which emulates the message list format provided exposed model providers.

jer96 avatar Jul 23 '25 20:07 jer96

So based on my understanding kind of based on the notes I have read in this issue https://github.com/a2aproject/A2A/issues/602, A2A doesn't have a good way to implement this which is where it is recommended to use DataPart or Metadata and extract the data from the metadata in the message send request. To me it feels like DataPart is the better approach (or at least bare minimum strands should allow me to invoke a model with the data from a DataPart in the A2A call).

I think there are use cases where if let's say in a Multi-Agent system if the context from one agent contains information that may be relevant to another (let's say if an IDE/CLI code assistant wanted to pass context of a user's conversation and a summary of what has happened thus far with maybe snippets of the code that has been worked on thus far) that DataParts are applicable. I think saying that the Strands Agent is the only thing that will always originate the conversation context isn't quite accurate. Also in the A2A Server implementation how do we expect with Strands to isolate context from a conversation with User A that is separate then context with a conversation with User B. I don't see in the A2A Specification https://a2a-protocol.org/latest/specification/#711-messagesendparams-object to specify user-id, conversation-id or context-id or something that would allow us on the Strands side to know what context we should use for this conversation. Since a task is created when the Message Send call is made we can't hijack something like the task-id https://a2a-protocol.org/latest/specification/#73-tasksget to be able to then get the history. But it still seems like even if we could it still wouldn't be quite what we want because as far as I can tell Strands doesn't segment context based on a task-id that I then could pass via metadata in the A2A send message call.

blakeromano avatar Jul 24 '25 15:07 blakeromano

Hi this is related to https://github.com/strands-agents/sdk-python/issues/535 as both cover the expansion of the Strands tool content types.

dbschmigelski avatar Jul 25 '25 15:07 dbschmigelski

thanks for the context @blakeromano, this helps. i'd like to distill these thoughts into concrete feature requests:

  1. support passing DataPart and FilePart A2A input payloads to the underlying Strands agent

Also in the A2A Server implementation how do we expect with Strands to isolate context from a conversation with User A that is separate then context with a conversation with User B

independent of the A2A server implementation, an instance of a Strands agents represents a single session. as such, the A2A server implementation inherits this behavior. however, we did recently introduced session management into the SDK which may help here.

i also see in the A2A task spec that there is this notion of a contextId which could potentially align with a Strands agent's sessionId 🤔 ? so the second feature seems to be:

  1. session persistence for Strands agents behind the A2AServer interface

at a high level are these representative? if you are aligned we can extract these into separate issues and hydrate them with detailed descriptions.

jer96 avatar Jul 25 '25 15:07 jer96

I think I agree with you on your first set of issue(s).

The context part I still may be missing because how do I pass that when I make a send message call (since there is no send task/create task call)? Is it metadata? Is it something else?

blakeromano avatar Jul 25 '25 17:07 blakeromano

currently, additional metadata would need to be included in the message request. all preceding messages sent to the agent will be persisted in memory and the most recent message will be appended to the end of the agent's internal messages array and sent to the model.

jer96 avatar Jul 30 '25 15:07 jer96

hi @blakeromano please reopen if there are any additional requests or questions that you may have related to A2A.

jer96 avatar Aug 20 '25 15:08 jer96