
Exposing Amazon Bedrock Agents with the Agent2Agent (A2A) Protocol
The Agent2Agent (A2A) Protocol enables AI agents to communicate across different platforms. This guide shows how to implement an Amazon Bedrock Agent using A2A, allowing it to work with other A2A-compliant agents. By connecting Bedrock Agents through A2A, we can create powerful multi-agent systems for complex workflows.
Eryan Ariobowo
Amazon Employee
Published Jun 3, 2025
Before diving into the implementation, let's briefly understand what the A2A protocol is and why it matters.
The A2A protocol is an open standard that enables different AI agents to communicate with each other regardless of their underlying implementation. It provides a common language for agents to:
- Discover each other's capabilities
- Send and receive messages
- Execute tasks
- Stream responses
- Maintain conversation context
This interoperability is crucial for building complex AI systems where specialized agents need to collaborate to solve problems.
In this article our goal is to create an A2A server that wraps an existing Amazon Bedrock Agent, exposing it through the A2A protocol. The server will:
- Define an Agent Card that describes the Bedrock Agent's capabilities
- Handle incoming A2A requests and translate them to Bedrock Agent API calls
- Process responses from the Bedrock Agent and format them according to the A2A protocol
- Support both synchronous and streaming interactions
The implementation consists of three main components:
- BedrockAgentWrapper: Handles communication with the Amazon Bedrock Agent API
- BedrockAgentTaskManager: Manages A2A tasks and translates between A2A protocol and Bedrock Agent API
- A2A Server: Exposes the agent's capabilities via HTTP endpoints
Let's start by setting up our development environment and creating the necessary files for our Bedrock Agent wrapper. Follow these steps to get started:
First, clone the A2A repository to get access to the core protocol implementation and sample code:
Create a new directory for your Bedrock Agent wrapper in the samples directory:
We will create the essential files we'll need for our implementation:
__init__.py
: Makes the directory a Python package__main__.py
: Entry point for running the serverbedrock_agent_wrapper.py
: Wrapper for the Bedrock Agent APItask_manager.py
: Manages A2A tasks and translates between A2A and Bedrockserver.py
: Server implementation for the A2A protocolrun.py
: Helper script to run the serverpyproject.toml
: Project dependencies and metadata- .
env
: Environment variables config file
Create a
pyproject.toml
file with the necessary dependencies:We need to set up our environment with the necessary dependencies and configuration. The project uses a .env file to store configuration parameters, making it easy to adapt for different Bedrock Agents.
Here's what a typical .env file looks like:
This configuration-driven approach allows you to easily switch between different Bedrock Agents by simply updating the environment variables, without changing any code.
Now, let's implement the core components of our Bedrock Agent wrapper.
The BedrockAgentWrapper class is responsible for communicating with the Amazon Bedrock Agent API. It provides a clean interface for the rest of the application to interact with Bedrock Agents without worrying about the underlying API details.
The wrapper abstracts away the complexities of the Bedrock Agent API, providing a simple invoke method that takes a user query and returns the agent's response. This makes it easy to integrate with the A2A protocol.
The BedrockAgentTaskManager class extends the A2A SDK's InMemoryTaskManager to handle task lifecycle management. It's responsible for:
- Validating incoming requests
- Invoking the Bedrock Agent
- Managing task state
- Formatting responses according to the A2A protocol
The task manager handles the translation between A2A protocol concepts (like tasks, artifacts, and messages) and the Bedrock Agent API. This ensures that the Bedrock Agent can be seamlessly integrated into the A2A ecosystem.
The main entry point for our application is the
__main__.py
file, which sets up the A2A server with the appropriate configuration:The server configuration is highly customizable, allowing you to define:
- The agent's name, description, and provider information
- The skills and capabilities of the agent
- The supported input and output modes
- 4The host and port for the server
One of the key strengths of this implementation is its flexibility. By using environment variables and command-line arguments, we can make the code generic enough to work with any Bedrock Agent without modification.
If you want to make it more generic, here's how:
- Dynamic Skill Discovery: Instead of hardcoding the agent's skills, we could query the Bedrock Agent API to discover its capabilities and generate the A2A skills dynamically.
- Customizable Agent Card: Allow users to provide a custom agent card template in the .env file, which can be merged with the dynamically discovered capabilities.
- Support for Different Authentication Methods: Add support for different AWS authentication methods, such as IAM roles, AWS profiles, or temporary credentials.
- Content Type Negotiation: Enhance the content type handling to support more formats beyond plain text, such as JSON, Markdown, or HTML.
To run the server, you simply need to:
- Set up your .env file with the appropriate Bedrock Agent configuration
- Install the dependencies
- Run the server
The server will start and listen for connections on the specified host and port. You can then interact with it using any A2A client.
Once the server is running, you can interact with it using any A2A-compliant client. The A2A repository includes a CLI client that you can use for testing:
This will start a CLI interface where you can send messages to your Bedrock Agent through the A2A protocol.
Exposing Amazon Bedrock Agents through the A2A protocol opens up exciting possibilities for building complex, collaborative AI systems. By following the approach outlined in this article you can make your Bedrock Agents interoperable with other A2A-compliant agents, enabling them to work together to solve complex problems.
The implementation we've explored is highly flexible and can be adapted to work with any Bedrock Agent by simply updating the configuration in the .env file. This makes it easy to integrate your existing Bedrock Agents into the A2A ecosystem without significant code changes.
As the A2A protocol continues to evolve, we can expect even more powerful integration possibilities between different AI agent frameworks. By adopting this open standard, we're taking a step toward a future where AI agents can seamlessly collaborate, regardless of their underlying implementation.
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.