Skip to content

Commit 284d323

Browse files
committed
AWS Bedrock provider support
- AWS Bedrock provider, supporting multiple model families (Anthropic Claude, Amazon Titan, Meta Llama, and Mistral). Signed-off-by: Alvaro Saurin <[email protected]>
1 parent 20b398a commit 284d323

File tree

8 files changed

+898
-3
lines changed

8 files changed

+898
-3
lines changed

docs/USAGE.md

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ agents with specialized capabilities and tools. It features:
1515
- **📦 Agent distribution** via Docker registry integration
1616
- **🔒 Security-first design** with proper client scoping and resource isolation
1717
- **⚡ Event-driven streaming** for real-time interactions
18-
- **🧠 Multi-model support** (OpenAI, Anthropic, Gemini, [Docker Model Runner (DMR)](https://docs.docker.com/ai/model-runner/))
18+
- **🧠 Multi-model support** (OpenAI, Anthropic, Gemini, Amazon Bedrock, [Docker Model Runner (DMR)](https://docs.docker.com/ai/model-runner/))
1919

2020

2121
## Why?
@@ -193,7 +193,7 @@ cagent run ./agent.yaml /analyze
193193

194194
| Property | Type | Description | Required |
195195
|---------------------|------------|------------------------------------------------------------------------------|----------|
196-
| `provider` | string | Provider: `openai`, `anthropic`, `google`, `dmr` ||
196+
| `provider` | string | Provider: `openai`, `anthropic`, `google`, `amazon-bedrock`, `dmr` ||
197197
| `model` | string | Model name (e.g., `gpt-4o`, `claude-sonnet-4-0`, `gemini-2.5-flash`) ||
198198
| `temperature` | float | Randomness (0.0-1.0) ||
199199
| `max_tokens` | integer | Response length limit ||
@@ -209,7 +209,7 @@ cagent run ./agent.yaml /analyze
209209
models:
210210
model_name:
211211
provider: string # Provider: openai, anthropic, google, dmr
212-
model: string # Model name: gpt-4o, claude-3-7-sonnet-latest, gemini-2.5-flash, qwen3:4B, ...
212+
model: string # Model name: gpt-4o, claude-3-7-sonnet-latest, amazon-bedrock, gemini-2.5-flash, qwen3:4B, ...
213213
temperature: float # Randomness (0.0-1.0)
214214
max_tokens: integer # Response length limit
215215
top_p: float # Nucleus sampling (0.0-1.0)
@@ -334,6 +334,12 @@ models:
334334
provider: google
335335
model: gemini-2.5-flash
336336
337+
# Amazon Bedrock
338+
models:
339+
bedrock-claude:
340+
provider: amazon-bedrock
341+
model: anthropic.claude-3-5-sonnet-20241022-v2:0
342+
337343
# Docker Model Runner (DMR)
338344
models:
339345
qwen:
@@ -461,6 +467,57 @@ These options work alongside `max_tokens` (which sets `--context-size`) and `run
461467
- Endpoint empty in status: ensure the Model Runner is running, or set `base_url` manually
462468
- Flag parsing: if using a single string, quote properly in YAML; you can also use a list
463469

470+
#### Amazon Bedrock provider usage
471+
472+
The `amazon-bedrock` provider enables access to various AI models hosted on AWS Bedrock, including Anthropic Claude, Amazon Titan, Meta Llama, and Mistral models.
473+
474+
**Authentication:**
475+
476+
The Bedrock provider supports two authentication methods:
477+
478+
1. **Bearer Token** (via `AWS_BEDROCK_TOKEN` environment variable):
479+
- Use for custom authentication services or proxy scenarios
480+
- If set, the provider uses Bearer token authentication and skips AWS Signature v4 signing
481+
- Example: `export AWS_BEDROCK_TOKEN="your-token-here"`
482+
483+
2. **Standard AWS Credentials** (default chain):
484+
- Environment variables: `AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_SESSION_TOKEN`
485+
- AWS profile: `AWS_PROFILE` environment variable or default profile in `~/.aws/credentials`
486+
- IAM role (for EC2/ECS/Lambda environments)
487+
488+
**Configuration:**
489+
490+
Basic configuration:
491+
492+
```yaml
493+
models:
494+
bedrock-claude:
495+
provider: amazon-bedrock
496+
model: anthropic.claude-3-5-sonnet-20241022-v2:0
497+
temperature: 0.7
498+
max_tokens: 4000
499+
```
500+
501+
With custom region:
502+
503+
```yaml
504+
models:
505+
bedrock-claude:
506+
provider: amazon-bedrock
507+
model: anthropic.claude-3-5-sonnet-20241022-v2:0
508+
provider_opts:
509+
region: us-west-2 # Optional, defaults to AWS_REGION or us-east-1
510+
```
511+
512+
With custom endpoint (for VPC endpoints or proxies):
513+
514+
```yaml
515+
models:
516+
bedrock-claude:
517+
provider: amazon-bedrock
518+
model: anthropic.claude-3-5-sonnet-20241022-v2:0
519+
base_url: https://bedrock-runtime.us-east-1.amazonaws.com
520+
```
464521

465522
### Alloy models
466523

examples/bedrock.yaml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
version: "2"
2+
3+
agents:
4+
root:
5+
model: claude
6+
description: "Test multi-tool agent"
7+
instruction: |
8+
You are a test agent that demonstrates multi-tool calling.
9+
10+
⚠️ CRITICAL INSTRUCTIONS - YOU MUST FOLLOW THESE EXACTLY:
11+
12+
When the user asks you to call multiple tools:
13+
1. Call the FIRST tool and wait for its result
14+
2. After receiving the first result, you MUST call the SECOND tool
15+
3. After receiving the second result, ONLY THEN respond to the user
16+
17+
DO NOT respond with text after calling just one tool.
18+
DO NOT say "I'll call the tools" - JUST CALL THEM.
19+
DO NOT provide your final answer until you have called ALL required tools.
20+
21+
If the task requires N tools, you must make N separate tool calls.
22+
Each tool call must be followed by receiving its result before the next tool call.
23+
24+
Example correct sequence:
25+
- Tool Call 1 → Receive Result 1
26+
- Tool Call 2 → Receive Result 2
27+
- Final Response with both results
28+
29+
WRONG (do not do this):
30+
- Tool Call 1 → Receive Result 1 → Final Response (MISSING TOOL 2!)
31+
32+
max_iterations: 20
33+
toolsets:
34+
- type: shell
35+
36+
models:
37+
claude:
38+
provider: amazon-bedrock
39+
model: us.anthropic.claude-sonnet-4-5-20250929-v1:0
40+
temperature: 0.7
41+
max_tokens: 4000
42+
# Optional: specify AWS region (defaults to AWS_REGION env var or us-east-1)
43+
# provider_opts:
44+
# region: us-west-2

go.mod

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ require (
1313
github.com/alpkeskin/gotoon v0.1.1
1414
github.com/anthropics/anthropic-sdk-go v1.19.0
1515
github.com/atotto/clipboard v0.1.4
16+
github.com/aws/aws-sdk-go-v2 v1.39.3
17+
github.com/aws/aws-sdk-go-v2/config v1.31.13
18+
github.com/aws/aws-sdk-go-v2/service/bedrockruntime v1.41.1
19+
github.com/aws/smithy-go v1.23.1
1620
github.com/aymanbagabas/go-udiff v0.3.1
1721
github.com/bmatcuk/doublestar/v4 v4.9.1
1822
github.com/charmbracelet/glamour/v2 v2.0.0-20251106195642-800eb8175930
@@ -61,6 +65,17 @@ require (
6165
cloud.google.com/go/compute/metadata v0.9.0 // indirect
6266
dario.cat/mergo v1.0.2 // indirect
6367
github.com/JohannesKaufmann/dom v0.2.0 // indirect
68+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.2 // indirect
69+
github.com/aws/aws-sdk-go-v2/credentials v1.18.17 // indirect
70+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.10 // indirect
71+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.10 // indirect
72+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.10 // indirect
73+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4 // indirect
74+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.2 // indirect
75+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.10 // indirect
76+
github.com/aws/aws-sdk-go-v2/service/sso v1.29.7 // indirect
77+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.2 // indirect
78+
github.com/aws/aws-sdk-go-v2/service/sts v1.38.7 // indirect
6479
github.com/ProtonMail/go-crypto v1.1.6 // indirect
6580
github.com/aymerick/douceur v0.2.0 // indirect
6681
github.com/bahlo/generic-list-go v0.2.0 // indirect

go.sum

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,36 @@ github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPd
4343
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
4444
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
4545
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
46+
github.com/aws/aws-sdk-go-v2 v1.39.3 h1:h7xSsanJ4EQJXG5iuW4UqgP7qBopLpj84mpkNx3wPjM=
47+
github.com/aws/aws-sdk-go-v2 v1.39.3/go.mod h1:yWSxrnioGUZ4WVv9TgMrNUeLV3PFESn/v+6T/Su8gnM=
48+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.2 h1:t9yYsydLYNBk9cJ73rgPhPWqOh/52fcWDQB5b1JsKSY=
49+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.7.2/go.mod h1:IusfVNTmiSN3t4rhxWFaBAqn+mcNdwKtPcV16eYdgko=
50+
github.com/aws/aws-sdk-go-v2/config v1.31.13 h1:wcqQB3B0PgRPUF5ZE/QL1JVOyB0mbPevHFoAMpemR9k=
51+
github.com/aws/aws-sdk-go-v2/config v1.31.13/go.mod h1:ySB5D5ybwqGbT6c3GszZ+u+3KvrlYCUQNo62+hkKOFk=
52+
github.com/aws/aws-sdk-go-v2/credentials v1.18.17 h1:skpEwzN/+H8cdrrtT8y+rvWJGiWWv0DeNAe+4VTf+Vs=
53+
github.com/aws/aws-sdk-go-v2/credentials v1.18.17/go.mod h1:Ed+nXsaYa5uBINovJhcAWkALvXw2ZLk36opcuiSZfJM=
54+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.10 h1:UuGVOX48oP4vgQ36oiKmW9RuSeT8jlgQgBFQD+HUiHY=
55+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.10/go.mod h1:vM/Ini41PzvudT4YkQyE/+WiQJiQ6jzeDyU8pQKwCac=
56+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.10 h1:mj/bdWleWEh81DtpdHKkw41IrS+r3uw1J/VQtbwYYp8=
57+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.10/go.mod h1:7+oEMxAZWP8gZCyjcm9VicI0M61Sx4DJtcGfKYv2yKQ=
58+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.10 h1:wh+/mn57yhUrFtLIxyFPh2RgxgQz/u+Yrf7hiHGHqKY=
59+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.10/go.mod h1:7zirD+ryp5gitJJ2m1BBux56ai8RIRDykXZrJSp540w=
60+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4 h1:WKuaxf++XKWlHWu9ECbMlha8WOEGm0OUEZqm4K/Gcfk=
61+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.4/go.mod h1:ZWy7j6v1vWGmPReu0iSGvRiise4YI5SkR3OHKTZ6Wuc=
62+
github.com/aws/aws-sdk-go-v2/service/bedrockruntime v1.41.1 h1:sscdABXtedWQ+5I0YnxawJwrX1YzbPhIs7TklRaRDpk=
63+
github.com/aws/aws-sdk-go-v2/service/bedrockruntime v1.41.1/go.mod h1:LVJ9jAJ1nuUyhovH5z7GAA/FktQOMarcZgGeqiHQJPo=
64+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.2 h1:xtuxji5CS0JknaXoACOunXOYOQzgfTvGAc9s2QdCJA4=
65+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.2/go.mod h1:zxwi0DIR0rcRcgdbl7E2MSOvxDyyXGBlScvBkARFaLQ=
66+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.10 h1:DRND0dkCKtJzCj4Xl4OpVbXZgfttY5q712H9Zj7qc/0=
67+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.10/go.mod h1:tGGNmJKOTernmR2+VJ0fCzQRurcPZj9ut60Zu5Fi6us=
68+
github.com/aws/aws-sdk-go-v2/service/sso v1.29.7 h1:fspVFg6qMx0svs40YgRmE7LZXh9VRZvTT35PfdQR6FM=
69+
github.com/aws/aws-sdk-go-v2/service/sso v1.29.7/go.mod h1:BQTKL3uMECaLaUV3Zc2L4Qybv8C6BIXjuu1dOPyxTQs=
70+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.2 h1:scVnW+NLXasGOhy7HhkdT9AGb6kjgW7fJ5xYkUaqHs0=
71+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.35.2/go.mod h1:FRNCY3zTEWZXBKm2h5UBUPvCVDOecTad9KhynDyGBc0=
72+
github.com/aws/aws-sdk-go-v2/service/sts v1.38.7 h1:VEO5dqFkMsl8QZ2yHsFDJAIZLAkEbaYDB+xdKi0Feic=
73+
github.com/aws/aws-sdk-go-v2/service/sts v1.38.7/go.mod h1:L1xxV3zAdB+qVrVW/pBIrIAnHFWHo6FBbFe4xOGsG/o=
74+
github.com/aws/smithy-go v1.23.1 h1:sLvcH6dfAFwGkHLZ7dGiYF7aK6mg4CgKA/iDKjLDt9M=
75+
github.com/aws/smithy-go v1.23.1/go.mod h1:LEj2LM3rBRQJxPZTB4KuzZkaZYnZPnvgIhb4pu07mx0=
4676
github.com/aymanbagabas/go-udiff v0.3.1 h1:LV+qyBQ2pqe0u42ZsUEtPiCaUoqgA9gYRDs3vj1nolY=
4777
github.com/aymanbagabas/go-udiff v0.3.1/go.mod h1:G0fsKmG+P6ylD0r6N/KgQD/nWzgfnl8ZBcNLgcbrw8E=
4878
github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuPk=

0 commit comments

Comments
 (0)