
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.
- 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)
- Install CDK and dependencies
- Configure your environment
- Bootstrap your AWS account and region
python3 -m venv .venv
source .venv/bin/activate # On Windows use: .venv\Scripts\activate.bat
pip install -r requirements.txt
- Supervisor agent
- Orders agent
- Support ticket agent
- Escalations agent
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
...
def _create_agents(self) -> None:
support_action_groups = ActionGroup().from_file(
"agent_action_group_support_data.json", self.functions.tickets
)
# Create support agent
self.support_agent = Agent(
self,
"SupportAgent",
action_groups=support_action_groups,
agent_name="mac-ticket",
agent_description="Ticket Support",
agent_instruction=(
"Usted es un amable agente de soporte a cliente que ayuda creando tickets y entregando informacion de tickets de atencion de postventa."
),
foundation_model=DEFAULT_MODEL_ID,
)
self.support_agent.create_alias("mac-ticket-alias")
...
- 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
- Modify the corresponding agent_action_group_xxx_data.json files
- Each file defines the actions available to that specific agent
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[
{
"action_group_name": "OrdersActionGroup",
"description": "Order status",
"lambda_": "",
"functions": [
{
"name": "getOrderStatus",
"description": "Use this when you need to get the customer's order information",
"parameters": [
{
"name": "order_number",
"type": "string",
"description": "8-digit order number. For example 12345678",
"required": 1
},
...
]
}
]
}
...
]
supervisor_agent
support_agent
:1
2
3
4
5
6
7
self.supervisor_agent.add_collaborator(
self.support_agent.alias,
"support-tickets",
"Use this agent when you need to create a customer support ticket or get ticket status, use this before escalation. \
You can only create tickets and inform status. ",
)
...
orders table
:order_number | delivery_date | id_number | status | shipping_address |
---|---|---|---|---|
10026657 | 2024-08-06 | 44444444-4 | Pendiente Bodega | Calle las acacias 123, Providencia. Region Metropolitana |
10026656 | 2024-08-06 | 44444444-4 | Despacho Programado | Calle las acacias 123, Providencia. Region Metropolitana |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[USER] I'm having a problem with order 10026656.
[AGENT] Could you please provide me with your identity document number? This is typically an 8-digit number followed by a dash and a letter (K or a digit), which is needed to look up your order status.
[USER] 10192797-1
[AGENT] I've found the details for your order 10026656:
- Status: Scheduled for Shipping (Despacho Programado)
- Delivery Date: August 6, 2024
- Shipping Address: Calle las acacias 123, Providencia, Metropolitan Region
Is there anything specific about the order you're having a problem with?
[USER] I'd like to create a ticket for support since the order has not been delivered yet.
[AGENT] I've created a support ticket for your order.
- Ticket Number: 202502101332
- Order Number: 10026656
- Current Status: Open
Our support team will investigate the delivery issue and contact you soon. Is there anything else I can help you with today?
[USER] What is the status of ticket 202502101332?
[AGENT] The status of ticket 202502101332 is currently "open".
- Order Number: 10026656
- Issue Details: Customer reports order has not been delivered as expected
- Our support team is investigating the shipping status and will work on resolving the delivery issue.
- 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)
- Using CDK CLI: Run
cdk destroy
- Using AWS Console: Navigate to CloudFormation and select "Delete"
Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.