0d3cb498a3
CI / Shell Format Check (push) Has been cancelled
CI / Check Ruby (3.4) (push) Has been cancelled
CI / CI Config (push) Has been cancelled
CI / Test on Node ${{ matrix.node }} and ${{ matrix.os }}${{ matrix.shard && format(' (shard {0}/3)', matrix.shard) || '' }} (push) Has been cancelled
CI / Build on Node ${{ matrix.node }} (push) Has been cancelled
CI / Style Check (push) Has been cancelled
CI / Generate Assets (push) Has been cancelled
CI / Check Python (3.14) (push) Has been cancelled
CI / Check Python (3.9) (push) Has been cancelled
CI / Build Docs (push) Has been cancelled
CI / Code Scan Action (push) Has been cancelled
CI / Site tests (push) Has been cancelled
CI / webui tests (push) Has been cancelled
CI / Run Integration Tests (push) Has been cancelled
CI / Run Smoke Tests (push) Has been cancelled
CI / Go Tests (push) Has been cancelled
CI / Share Test (push) Has been cancelled
CI / Redteam (Production API) (push) Has been cancelled
CI / Redteam (Staging API) (push) Has been cancelled
CI / GitHub Actions Lint (push) Has been cancelled
CI / Check Ruby (3.0) (push) Has been cancelled
release-please / release-please (push) Has been cancelled
release-please / build (push) Has been cancelled
release-please / publish-npm (push) Has been cancelled
release-please / publish-npm-backfill (push) Has been cancelled
release-please / docker (push) Has been cancelled
release-please / publish-code-scan-action (push) Has been cancelled
release-please / attest-code-scan-action (push) Has been cancelled
Deploy local.promptfoo.app / Deploy to Cloudflare Pages (push) Has been cancelled
Test and Publish Multi-arch Docker Image / test (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-amd64 platform:linux/amd64 runner:ubuntu-latest]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / build-docker-and-push-digests (map[digest-suffix:linux-arm64 platform:linux/arm64 runner:ubuntu-24.04-arm]) (push) Has been cancelled
Test and Publish Multi-arch Docker Image / merge-docker-digests (push) Has been cancelled
Test and Publish Multi-arch Docker Image / Attest Multi-arch Image (push) Has been cancelled
Validate Renovate Config / Validate Renovate Configuration (push) Has been cancelled
216 lines
5.3 KiB
Markdown
216 lines
5.3 KiB
Markdown
# amazon-bedrock/agents (AWS Bedrock Agents Example)
|
|
|
|
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:
|
|
|
|
```bash
|
|
npx promptfoo@latest init --example amazon-bedrock/agents
|
|
cd amazon-bedrock/agents
|
|
```
|
|
|
|
## Prerequisites
|
|
|
|
1. An AWS account with Bedrock Agents access
|
|
2. One or more deployed Bedrock agents (get agent IDs from the AWS Console)
|
|
3. AWS credentials configured (via environment variables, AWS CLI, or IAM role)
|
|
4. Install the required AWS SDK:
|
|
|
|
```bash
|
|
npm install @aws-sdk/client-bedrock-agent-runtime
|
|
```
|
|
|
|
## Setup
|
|
|
|
1. **Get your Agent ID(s)**:
|
|
- Go to the AWS Bedrock Console
|
|
- Navigate to Agents
|
|
- Copy your agent ID(s) (format: `ABCDEFGHIJ`)
|
|
|
|
2. **Configure AWS Credentials** (choose one method):
|
|
|
|
Via environment variables:
|
|
|
|
```bash
|
|
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:
|
|
|
|
```bash
|
|
aws configure --profile my-bedrock-profile
|
|
```
|
|
|
|
Via IAM role (if running on EC2/Lambda)
|
|
|
|
3. **Choose your configuration**:
|
|
- `promptfooconfig.yaml`: Basic single-agent configuration
|
|
- `promptfooconfig.multi-agent.yaml`: Advanced multi-agent system configuration
|
|
|
|
## Running the Examples
|
|
|
|
### Single Agent Example
|
|
|
|
```bash
|
|
# Run basic agent evaluation
|
|
npx promptfoo eval -c promptfooconfig.yaml
|
|
|
|
# View results in the web UI
|
|
npx promptfoo view
|
|
```
|
|
|
|
### Multi-Agent Example
|
|
|
|
```bash
|
|
# Run multi-agent system evaluation
|
|
npx promptfoo eval -c promptfooconfig.multi-agent.yaml
|
|
|
|
# View results in the web UI
|
|
npx promptfoo view
|
|
```
|
|
|
|
## Configuration Options
|
|
|
|
### Basic Usage
|
|
|
|
```yaml
|
|
providers:
|
|
- bedrock-agent:YOUR_AGENT_ID
|
|
```
|
|
|
|
### Advanced Single Agent Configuration
|
|
|
|
```yaml
|
|
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
|
|
```
|
|
|
|
### Multi-Agent System Configuration
|
|
|
|
```yaml
|
|
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
|
|
```
|
|
|
|
## Features
|
|
|
|
### Session Management
|
|
|
|
The provider supports maintaining conversation state across multiple interactions:
|
|
|
|
```yaml
|
|
config:
|
|
sessionId: my-session-123 # Use the same session ID for related queries
|
|
```
|
|
|
|
### Memory Integration
|
|
|
|
Enable agent memory for context-aware responses:
|
|
|
|
```yaml
|
|
config:
|
|
memoryId: LONG_TERM_MEMORY # or SHORT_TERM_MEMORY
|
|
```
|
|
|
|
### Trace Information
|
|
|
|
Get detailed execution traces including tool calls and reasoning:
|
|
|
|
```yaml
|
|
config:
|
|
enableTrace: true # Response will include trace metadata
|
|
```
|
|
|
|
## Testing Scenarios
|
|
|
|
### Single Agent Tests
|
|
|
|
The basic config includes tests for:
|
|
|
|
- Basic agent responses
|
|
- Tool/function calling (e.g., calculator)
|
|
- Memory retention
|
|
- Multi-turn conversations
|
|
|
|
### Multi-Agent System Tests
|
|
|
|
The multi-agent config includes tests for:
|
|
|
|
- Specialized agent capabilities (technical, billing, product)
|
|
- Cross-functional issue handling
|
|
- Agent collaboration and coordination
|
|
- Escalation management
|
|
- Performance and latency validation
|
|
|
|
## Multi-Agent System Architecture
|
|
|
|
The multi-agent example demonstrates a customer support system with specialized agents:
|
|
|
|
```text
|
|
Customer Query
|
|
↓
|
|
[Supervisor Agent] ← Monitors & Routes
|
|
↓
|
|
┌─────────────────┬─────────────────┬──────────────────┐
|
|
│ Tech Agent │ Billing Agent │ Product Agent │
|
|
│ (Technical) │ (Payments) │ (Recommendations)│
|
|
└─────────────────┴─────────────────┴──────────────────┘
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
1. **Authentication Error**: Ensure AWS credentials are properly configured
|
|
2. **Agent Not Found**: Verify the agent ID and region
|
|
3. **Permissions Error**: Check IAM permissions for `bedrock:InvokeAgent`
|
|
4. **Timeout**: Large agent responses may take time; adjust timeout if needed
|
|
5. **Multi-Agent Issues**: Ensure all agent IDs and aliases are correct in the config
|
|
|
|
## IAM Permissions
|
|
|
|
Your AWS credentials need the following permissions:
|
|
|
|
```json
|
|
{
|
|
"Version": "2012-10-17",
|
|
"Statement": [
|
|
{
|
|
"Effect": "Allow",
|
|
"Action": ["bedrock:InvokeAgent"],
|
|
"Resource": "arn:aws:bedrock:*:*:agent/*"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
## Learn More
|
|
|
|
- [AWS Bedrock Agents Documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/agents.html)
|
|
- [Promptfoo Documentation](https://promptfoo.dev/docs/providers/bedrock/)
|
|
- [Bedrock Agents Samples](https://github.com/awslabs/amazon-bedrock-agents-samples)
|