Project 3, Multi-Agent Support System — Future AWS Agent Engineer Nanodegree
A production-grade multi-agent customer support system built with the Strands Agents SDK and Amazon Bedrock AgentCore. The system routes customer support requests through an Orchestrator → Workers hierarchy, executes parallel multi-agent Retrieval-Augmented Generation (RAG) across domain Knowledge Bases backed by Amazon S3 Vectors, enforces enterprise safety policies via Bedrock Guardrails, maintains shared session state in DynamoDB with optimistic locking, and streams telemetry to CloudWatch Logs and AWS X-Ray.
For a deep dive into the engineering principles, architectural decisions, and step-by-step walkthrough, check out the following resources:
-
🌐 Technical Blog Post: Read full article
-
☁️ AWS Community Builders Article: Read on AWS Builders Center
-
🔗 Official Starter Template: udacity/cd14764-aws-agentic-c3-classroom/tree/main/project/starter
Customer Request
│
OrchestratorAgent (Claude Haiku 4.5 - routes requests, manages WorkflowState)
│
┌──┼──────────────────────────┬──────────────────┐
│ │ │ │
InventoryAgent PolicyAgent RefundAgent CommunicationAgent
(DynamoDB) (Multi-Agent RAG) (DynamoDB) (composes response)
│
┌───────────┼───────────┐
ReturnsPolicyRetriever ShippingPolicyRetriever WarrantyPolicyRetriever
(Bedrock KB) (Bedrock KB) (Bedrock KB)
└───────── run in PARALLEL ───────────┘
Shared State: DynamoDB WorkflowStateTable (with optimistic locking)
| Agent | Model | Responsibility | Tools |
|---|---|---|---|
| OrchestratorAgent | Claude Haiku 4.5 | Routes requests, creates/updates WorkflowState |
initialize_session, route_to_inventory_agent, route_to_policy_agent, route_to_refund_agent, route_to_communication_agent |
| InventoryAgent | Claude Sonnet 4.5 | Gathers order and customer facts from DynamoDB (no eligibility decisions) | check_order_status, get_customer_tier, list_customer_orders |
| PolicyAgent | Claude Sonnet 4.5 | Coordinates parallel RAG retrieval from 3 Knowledge Bases, synthesizes results | search_all_policies (internally fans out to 3 retriever sub-agents) |
| RefundAgent | Claude Sonnet 4.5 | Makes return/refund eligibility decisions (30-day Standard, 60-day Premium) | get_inventory_context, initiate_refund |
| CommunicationAgent | Claude Sonnet 4.5 | Reads full WorkflowState and composes final empathetic customer-facing response |
get_full_workflow_context |
- Tiered Model Routing: Uses Claude Haiku 4.5 in
OrchestratorAgentfor fast, low-cost routing and state updates, paired with Claude Sonnet 4.5 in domain workers for reasoning, policy synthesis, and response composition. - Parallel Multi-Agent RAG:
PolicyAgentruns three specialized retriever sub-agents (ReturnsPolicyRetriever,ShippingPolicyRetriever,WarrantyPolicyRetriever) concurrently viaThreadPoolExecutorand synthesizes retrieved passages. - Shared Workflow State with Optimistic Locking: DynamoDB
WorkflowStateTable(keyed bysession_id) tracks accumulated findings (version: 0throughversion: N) with conditional writes (ConditionExpression='version = :expected_version') and retries on version conflicts. - Enterprise Guardrails: Amazon Bedrock Guardrails enforce content filters (
SEXUAL,VIOLENCE,HATEatHIGH;INSULTS,MISCONDUCTatMEDIUM), PII handling (BLOCKcredit cards/SSNs;ANONYMIZEemail/phone), denied topics (CompetitorProducts,PricingNegotiations,LegalThreatsonSTANDARDtier with cross-region profileus.guardrail.v1:0), and managed profanity filtering under a published numbered version. - Session Memory: AgentCore Memory (
configure_memory) creates aSESSION_SUMMARY(summaryMemoryStrategy) resource with 7-day event retention (eventExpiryDuration=7). - Observability: AgentCore Observability routes execution logs to CloudWatch Logs (
INFOlevel) and distributed traces to AWS X-Ray (100%sampling rate /1.0) across theNovaMart-Orchestrator → Worker → Knowledge Basecall chain. - Serverless Vector Storage: Uses Amazon S3 Vectors (vector bucket + three indexes:
returns-policy-index,shipping-policy-index,warranty-policy-index) with self-managed Bedrock Knowledge Bases and Amazon Titan Embed Text v2 embeddings.
- Python 3.12 (matches runtime environment)
- AWS Account with Amazon Bedrock access enabled (
us-east-1) - IAM Permissions for Bedrock, Bedrock AgentCore, DynamoDB, S3, S3 Vectors, CloudFormation, CloudWatch Logs, and AWS X-Ray
- Node.js 20+ and uv if using the AgentCore CLI (
@aws/agentcore) for runtime packaging and deployment
Deploy infrastructure/starter_stack.yaml via AWS CloudFormation:
aws cloudformation deploy \
--template-file starter_stack.yaml \
--stack-name your-agentcore \
--capabilities CAPABILITY_NAMED_IAM \
--region us-east-1Validate stack deployment status:
aws cloudformation describe-stacks \
--stack-name your-agentcore \
--query "Stacks[0].StackStatus" \
--region us-east-1Confirm the status returns CREATE_COMPLETE.
Populate DynamoDB tables (agentcore-orders, agentcore-customers, agentcore-workflow-state) and upload policy documents under policies/returns/, policies/shipping/, and policies/warranty/ in the policy S3 bucket:
python infrastructure/seed_data.py
aws s3 ls s3://$(python -c "import config; print(config.POLICY_BUCKET)")/policies/ --recursiveInspect your stack's resource names using python config.py, then create three Self-managed Knowledge Bases in Amazon Bedrock → Knowledge Bases (do not select Managed KB):
| Setting | Returns KB | Shipping KB | Warranty KB |
|---|---|---|---|
| Name | novamart-returns-policy-kb |
novamart-shipping-policy-kb |
novamart-warranty-policy-kb |
| S3 Data Source Prefix | policies/returns/ |
policies/shipping/ |
policies/warranty/ |
| Embedding Model | Amazon Titan Embed Text v2 | Amazon Titan Embed Text v2 | Amazon Titan Embed Text v2 |
| Vector Store | S3 Vectors → Use an existing vector bucket | S3 Vectors → Use an existing vector bucket | S3 Vectors → Use an existing vector bucket |
| S3 Vectors Bucket | Vector Bucket from python config.py (udacity-agentcore-vectors-…) |
Vector Bucket from python config.py (udacity-agentcore-vectors-…) |
Vector Bucket from python config.py (udacity-agentcore-vectors-…) |
| Vector Index | returns-policy-index |
shipping-policy-index |
warranty-policy-index |
Click Sync on each Knowledge Base after creation, then copy the resulting Knowledge Base IDs into .env:
RETURNS_KB_ID=<your-returns-kb-id>
SHIPPING_KB_ID=<your-shipping-kb-id>
WARRANTY_KB_ID=<your-warranty-kb-id>starter/
├── config.py # Central configuration (CloudFormation exports + env vars)
├── infrastructure/
│ ├── starter_stack.yaml # CloudFormation template (DynamoDB, S3, S3 Vectors, IAM, CloudWatch)
│ └── seed_data.py # Seeds mock customers, orders, and S3 policy documents
├── src/
│ ├── agent_orchestrator.py # Multi-agent graph, guardrails, AgentCore deploy, memory, observability
│ ├── agent_utils.py # Terminal trace UI and agent formatting helpers
│ ├── agent_observability.py # @tool X-Ray instrumentation, logging, and observability config helpers
│ ├── agentcore_cli.py # AgentCore CLI staging, configuration, and deployment wrapper
│ └── bedrock_kb_retrieval.py # Bedrock Knowledge Base retrieval helper
└── tests/
└── test_agent.py # Task-by-task validation suite (task2 through task6, all)
OrchestratorAgent delegates all work to specialist agents and enforces six deterministic routing rules:
| Rule | Trigger | Action |
|---|---|---|
| 1 | Every request, always | Call initialize_session first |
| 2 | Order status / return / refund requests | Call route_to_inventory_agent first, then route_to_refund_agent |
| 3 | Policy meaning questions (return windows, shipping rates, warranty terms) | Call route_to_policy_agent |
| 4 | Account questions ("what is my tier?", "am I premium?") | Call route_to_inventory_agent — never route_to_policy_agent |
| 5 | Math / calculation questions | Skip Inventory, Policy, and Refund; route to CommunicationAgent |
| 6 | Every request, always (last step) | Call route_to_communication_agent to compose the final response |
Run the full deployment pipeline from src/agent_orchestrator.py:
python src/agent_orchestrator.py deployThis pipeline executes:
- Builds all five Strands agents (
InventoryAgent,RefundAgent,PolicyAgent,CommunicationAgent,OrchestratorAgent). - Creates and versions the Bedrock Guardrail (
create_guardrail()→create_guardrail_version()). - Stages runtime code and deploys to Amazon Bedrock AgentCore Runtime (
deploy_to_agentcore_runtime()). - Provisions session memory with a 7-day
SESSION_SUMMARYstrategy (configure_memory()). - Enables CloudWatch Logs (
INFO) and AWS X-Ray tracing at100%sampling (configure_observability()). - Optionally registers Lambda targets on an AgentCore Gateway (
deploy_agentcore_gateway()) ifORDERS_FUNCTION,POLICY_FUNCTION, orCUSTOMERS_FUNCTIONare set.
# Run local test scenarios with X-Ray tracing
python src/agent_orchestrator.py test
# Launch interactive terminal chat
python src/agent_orchestrator.py chat
# Invoke deployed AgentCore Runtime
python src/agent_orchestrator.py invoke "What is the return policy for premium customers?" CUST-002
# Run HTTP server (used inside AgentCore Runtime)
python src/agent_orchestrator.py serveValidate your implementation by task or across the entire suite using tests/test_agent.py:
python tests/test_agent.py task2 # Test multi-agent orchestration
python tests/test_agent.py task3 # Test AgentCore deployment + guardrails
python tests/test_agent.py task4 # Test memory
python tests/test_agent.py task5 # Test Bedrock Knowledge Base configuration + retrieval
python tests/test_agent.py task6 # Test observability
python tests/test_agent.py all # Run all tests| Test Suite | What It Validates |
|---|---|
task2 |
Instantiates InventoryAgent (3 tools), PolicyAgent (1 tool), and OrchestratorAgent (5 routing tools); verifies Haiku vs. Sonnet model tiering; statically verifies ThreadPoolExecutor usage in build_policy_agent(). |
task3 |
Confirms Bedrock Guardrail exists with expected content filter strengths, PII rules, three DENY topics, and profanity policy; verifies a published numbered GUARDRAIL_VERSION; checks AgentCore Runtime is READY (PUBLIC / HTTP) with required environment variables. |
task4 |
Verifies AgentCore Memory resource matching config.MEMORY_NAME is ACTIVE, uses SUMMARIZATION (SESSION_SUMMARY), and has a 7-day eventExpiryDuration. |
task5 |
Verifies RETURNS_KB_ID, SHIPPING_KB_ID, and WARRANTY_KB_ID are set, each KB is ACTIVE with amazon.titan-embed-text-v2:0 and a COMPLETE ingestion job, and search_all_policies() returns combined passages. |
task6 |
Verifies CloudWatch logging (AGENT_LOG_GROUP, INFO level, enabled) and X-Ray tracing (1.0 sampling rate, CloudWatch Logs destination, 100% default indexing rule), and checks recent NovaMart-Orchestrator traces. |
To inspect distributed traces visually after running python src/agent_orchestrator.py test or invoke, open AWS Console → CloudWatch → X-Ray traces → Service map (or X-Ray → Service map) and select Last 5 minutes to view the call graph from NovaMart-Orchestrator through worker agents and Knowledge Bases.
table.update_item(
Key={'session_id': session_id},
UpdateExpression=update_expr,
ConditionExpression='version = :expected_version',
ExpressionAttributeValues=expr_values
)with ThreadPoolExecutor(max_workers=3) as executor:
futures = {
executor.submit(_run_retriever, domain, ag, query): domain
for domain, ag in retrievers.items()
}
for future in as_completed(futures):
domain, res = future.result()
results[domain] = resversion_response = bedrock_client.create_guardrail_version(
guardrailIdentifier=guardrail_id,
description="Production version"
)
guardrail_version = version_response['version']AWS_REGION=us-east-1
PROJECT_NAME=udacity-agentcore
RETURNS_KB_ID=
SHIPPING_KB_ID=
WARRANTY_KB_ID=
AGENTCORE_RUNTIME_ARN=
GUARDRAIL_ID=
GUARDRAIL_VERSION=
ORDERS_FUNCTION=
POLICY_FUNCTION=
CUSTOMERS_FUNCTION=- Missing CloudFormation resources: Confirm stack
your-agentcore/udacity-agentcoreis inCREATE_COMPLETEinus-east-1and runpython infrastructure/seed_data.py. - Incorrect DynamoDB order lookups:
check_order_statusrequires bothcustomer_id(partition key) andorder_id(sort key). - Guardrail false positives on math queries: Ensure
topicPolicyConfigusestierConfig={"tierName": "STANDARD"},crossRegionConfig={"guardrailProfileIdentifier": "us.guardrail.v1:0"}, and definesPricingNegotiationsto exclude arithmetic calculations on specified prices and discounts. - No X-Ray traces visible: Confirm
AGENT_TRACING_ENABLED=true,AGENT_TRACE_SAMPLING_RATE=1.0, and IAM permissions forxray:PutTraceSegments, then check Last 5 minutes in the X-Ray Service Map.