AWS Logo
Menu
Amazon Bedrock Multi-Agent Collaboration System with Human escalation using CDK

Amazon Bedrock Multi-Agent Collaboration System with Human escalation using CDK

This project demonstrates the power of combining Multi-Agent Collaboration in Amazon Bedrock with AWS CDK custom constructs to create a flexible, scalable, and easily maintainable customer support and order management system.

Enrique Rodriguez
Amazon Employee
Published Feb 26, 2025
Building effective agent-based systems and multi-agent collaboration systems presents several challenges in today's rapidly evolving AI landscape. These include coordinating and communicating between multiple specialized agents, maintaining context and consistency between them, and scaling the system for increasing requests.
The Multi-Agent Collaboration capability in Amazon Bedrock addresses these challenges by providing featurs for creating and managing multi-agent systems. Key benefits include simplified agent creation and management, built-in support for inter-agent collaboration, integration with other AWS services through AWS Lambda, and removal of undifferentiated heavy-lifting for infrastructure, model, prompt and framework management.
Using Infrastructure as Code (IaC) with AWS CDK lets us quickly deploy and update AWS Infrastructure, track changes, and deploy consistently across environments.
This project demonstrates the power of combining Multi-Agent Collaboration in Amazon Bedrock with AWS CDK custom constructs to create a flexible, scalable, and easily maintainable customer support and order management system.

Architecture: Multi-Agent Customer Support with Escalation

The sample Multi-Agent Collaboration System is designed to streamline customer support and order management processes using Amazon Bedrock Agents. It leverages Amazon Bedrock to create and manage multiple specialized agents that can collaborate to provide comprehensive assistance to customers.
multi-agente
multi-agente
The system includes the following key components:
  • Supervisor Agent: Acts as the primary point of contact, managing overall customer interactions. Based on customer needs, it routes to specialized agents:
    • Support Agent: Handles creation and management of customer support tickets
    • Orders Agent: Provides customer order information and status
    • Escalation Agent: Manages escalation of complex issues to human specialists using the RETURN CONTROL capability (detailed below)
These agents collaborate to deliver a seamless customer experience - from answering order status inquiries to creating support tickets and escalating issues when needed. The system leverages AWS CDK (Cloud Development Kit) and integrates with AWS services like DynamoDB for data storage and Lambda for action execution.

Prerequisites

CDK Setup

New to CDK? Start here to learn how to:
  • Install CDK and dependencies
  • Configure your environment
  • Bootstrap your AWS account and region
Clone the repo:
git clone https://github.com/aws-samples/generative-ai-ml-latam-samples
Set up environment:
cd samples/multi-agent-collaboration
python3 -m venv .venv
source .venv/bin/activate # On Windows use: .venv\Scripts\activate.bat
pip install -r requirements.txt
Deploy the stack:
cdk deploy
It takes about 5 minutes to deploy. While we wait, let's review the code.

Agent Definition

The multi_agent_collaboration_stack.py file defines 4 agents:
  • Supervisor agent
  • Orders agent
  • Support ticket agent
  • Escalations agent
Here's an example of how the support agent is defined:
For each Agent, you can configure the following properties:
  • agent_name: Unique identifier for the agent
  • agent_description: Brief description of the agent's purpose
  • agent_instruction: Detailed instructions for the agent's behavior
  • foundation_model: The underlying model ID to use
  • action_groups: The set of actions the agent can perform

Action Groups

Action groups define the capabilities of an agent in Amazon Bedrock by specifying what operations it can perform. To configure an agent's capabilities:
  1. Modify the corresponding agent_action_group_xxx_data.json files
  2. Each file defines the actions available to that specific agent
Here's an example showing how the Orders Agent action group is structured:
You can change the AWS Lambda function in
ActionGroup().from_file("file.json", lambda_function)
or modify lambda code in lambdas/code folder.

Adding Collaborators

In order to create the collaboration, first enable collaboration for the supervisor_agent
self.supervisor_agent.enable_collaboration(how="SUPERVISOR_ROUTER") # SUPERVISOR / SUPERVISOR_ROUTER / DISABLED
Then you can add collaborators, indicating name and description (description will be used to decide which agent to route) for example for support_agent:

Testing the Agent

You can use evaluations tools like AgentEval to asses if the agent is responding correctly (results here). For manual test we can use Amazon Bedrock Agents Console.
Note: Synthetic data can be found in orders table:
order_numberdelivery_dateid_numberstatusshipping_address
100266572024-08-0644444444-4Pendiente BodegaCalle las acacias 123, Providencia. Region Metropolitana
100266562024-08-0644444444-4Despacho ProgramadoCalle las acacias 123, Providencia. Region Metropolitana
Conversation for problem with order

Testing the Escalation Return Control Flow

To enable human interaction when needed, we implemented the Escalation Agent. This agent detects situations requiring escalation and gathers relevant information (defined in agent_action_group_escalation_data). Let's test this functionality in the console:
Part 1: Getting Order Information and Creating a Ticket
Part 2: Escalation Process
About RETURN CONTROL
During testing, you'll see a prompt for Escalation Action Group Output. This is meant to simulate the result of escalation handling by company systems - it's not intended for end users to respond to. This prompt exists in the testing console solely to provide operation results back to the agent.
escalation
escalation

Security

For information about securing your implementation, please refer to the Amazon Bedrock Security documentation. This will help you configure Amazon Bedrock according to your security and compliance requirements.

Cost Considerations

The main cost components for this project include:
  • Amazon Bedrock: Charges only for input/output tokens when using Haiku 3.5 (with default inference profile). No additional charges for Bedrock Agents.
  • AWS Lambda: Likely covered by free tier for this demo (1 million free requests and 400,000 GB-seconds of compute time per month)
This solution uses serverless architecture with pay-as-you-go pricing (zero cost when not in use).

Decommissioning

To remove all resources:
  • Using CDK CLI: Run cdk destroy
  • Using AWS Console: Navigate to CloudFormation and select "Delete"
Enjoy building!
 

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.

Comments