examples/amazon-bedrock/agents/README.md
This example demonstrates how to use AWS Bedrock Agents with promptfoo to test and evaluate deployed AI agents, including both single-agent and multi-agent scenarios.
You can run this example with:
npx promptfoo@latest init --example amazon-bedrock/agents
cd amazon-bedrock/agents
An AWS account with Bedrock Agents access
One or more deployed Bedrock agents (get agent IDs from the AWS Console)
AWS credentials configured (via environment variables, AWS CLI, or IAM role)
Install the required AWS SDK:
npm install @aws-sdk/client-bedrock-agent-runtime
Get your Agent ID(s):
ABCDEFGHIJ)Configure AWS Credentials (choose one method):
Via environment variables:
export AWS_ACCESS_KEY_ID=your_access_key
export AWS_SECRET_ACCESS_KEY=your_secret_key
export AWS_REGION=us-east-1
Via AWS CLI profile:
aws configure --profile my-bedrock-profile
Via IAM role (if running on EC2/Lambda)
Choose your configuration:
promptfooconfig.yaml: Basic single-agent configurationpromptfooconfig.multi-agent.yaml: Advanced multi-agent system configuration# Run basic agent evaluation
npx promptfoo eval -c promptfooconfig.yaml
# View results in the web UI
npx promptfoo view
# Run multi-agent system evaluation
npx promptfoo eval -c promptfooconfig.multi-agent.yaml
# View results in the web UI
npx promptfoo view
providers:
- bedrock-agent:YOUR_AGENT_ID
providers:
- id: bedrock-agent:my-agent
config:
agentId: YOUR_AGENT_ID
agentAliasId: PROD_ALIAS # Optional: specific version/alias
region: us-east-1 # AWS region
sessionId: session-123 # Maintain conversation state
enableTrace: true # Get detailed execution traces
memoryId: SHORT_TERM_MEMORY # or LONG_TERM_MEMORY
providers:
# Technical Support Agent
- id: tech-agent
provider: bedrock-agent:TECH_AGENT_ID
config:
agentId: TECH_AGENT_ID
agentAliasId: TECH_ALIAS_ID
region: us-east-1
enableTrace: true
memoryId: LONG_TERM_MEMORY
# Billing Agent
- id: billing-agent
provider: bedrock-agent:BILLING_AGENT_ID
config:
agentId: BILLING_AGENT_ID
agentAliasId: BILLING_ALIAS_ID
region: us-east-1
enableTrace: true
The provider supports maintaining conversation state across multiple interactions:
config:
sessionId: my-session-123 # Use the same session ID for related queries
Enable agent memory for context-aware responses:
config:
memoryId: LONG_TERM_MEMORY # or SHORT_TERM_MEMORY
Get detailed execution traces including tool calls and reasoning:
config:
enableTrace: true # Response will include trace metadata
The basic config includes tests for:
The multi-agent config includes tests for:
The multi-agent example demonstrates a customer support system with specialized agents:
Customer Query
↓
[Supervisor Agent] ← Monitors & Routes
↓
┌─────────────────┬─────────────────┬──────────────────┐
│ Tech Agent │ Billing Agent │ Product Agent │
│ (Technical) │ (Payments) │ (Recommendations)│
└─────────────────┴─────────────────┴──────────────────┘
bedrock:InvokeAgentYour AWS credentials need the following permissions:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["bedrock:InvokeAgent"],
"Resource": "arn:aws:bedrock:*:*:agent/*"
}
]
}