You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+21Lines changed: 21 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,27 @@ reported the issue. Please try to include as much information as you can. Detail
20
20
* Anything unusual about your environment or deployment
21
21
22
22
23
+
## Development Setup
24
+
25
+
This project uses [uv](https://docs.astral.sh/uv/) for dependency management. Install uv if you haven't already, follow the installation [guide](https://docs.astral.sh/uv/getting-started/installation/#standalone-installer).
26
+
27
+
If you're developing or contributing to the `agentcore-rl-toolkit` package itself:
28
+
29
+
```bash
30
+
# Enter the repository
31
+
cd agentcore-rl-toolkit
32
+
33
+
# Create and activate uv environment
34
+
uv venv --python 3.13
35
+
source .venv/bin/activate
36
+
37
+
# Install with development dependencies
38
+
uv sync --frozen --extra dev
39
+
40
+
# Install pre-commit hooks
41
+
pre-commit install
42
+
```
43
+
23
44
## Contributing via Pull Requests
24
45
Contributions via pull requests are much appreciated. Before sending us a pull request, please ensure that:
Toolkit for Seamlessly Enabling RL Training on Any Agent with Bedrock AgentCore.
4
+
Toolkit to Seamlessly Enable RL Training on Any Agent with Bedrock AgentCore.
5
5
6
-
## Repo Structure
6
+
## Overview
7
7
8
-
-**Main package**: `agentcore-rl-toolkit` is a thin wrapper around of [bedrock-agentcore-sdk-python](https://github.com/aws/bedrock-agentcore-sdk-python/tree/main) that allows developers to start RL training their production agent with only a few lines of code change.
9
-
-**Examples**: Located in `examples/` directory, each with their own `pyproject.toml` and dependencies. Their corresponding docker files are located in `.bedrock_agentcore`, most of which have been generated automatically (see [instructions below](#prepare-docker-file)).
8
+
**AgentCore RL Toolkit (ART)** is an SDK that helps developers train their LLM agents using reinforcement learning (RL) with **AWS Bedrock AgentCore Runtime (ACR)**. It extends [bedrock-agentcore-sdk-python](https://github.com/aws/bedrock-agentcore-sdk-python/tree/main) to help adapt any existing production agents for RL training with minimal code changes.
10
9
10
+
The toolkit handles the complexity of:
11
+
-**Rollout collection**: Automatically captures agent interactions (conversations, tool calls, etc.) during RL training episodes
12
+
-**ACR integration**: Works seamlessly with ACR's auto-scaling and session management for efficient parallel rollout generation
13
+
-**Data pipeline**: Manages S3 storage and SQS messaging for asynchronous rollout delivery to training engines
14
+
-**Reward interface**: Provides a standard base class for implementing custom reward functions
15
+
16
+
## Installation
17
+
18
+
```bash
19
+
pip install agentcore-rl-toolkit
20
+
```
21
+
22
+
Or with uv:
23
+
```bash
24
+
uv add agentcore-rl-toolkit
25
+
```
26
+
27
+
To try the example agent applications without installing the package, each example under `examples/` has standalone dependencies. See individual example READMEs (e.g., `examples/strands_math_agent/README.md`).
28
+
29
+
### What is Bedrock AgentCore Runtime (ACR)?
30
+
31
+
ACR is AWS's serverless runtime for deploying LLM agents, which can be viewed as **Lambda functions with session continuity**:
32
+
33
+
-**Session routing**: Requests with the same session ID route to the same container, enabling multi-turn interactions with persistent state
34
+
-**Session isolation**: Different session IDs use separate runtime sessions (microVMs), providing strong security isolation between concurrent requests
35
+
-**Auto-scaling**: New runtime sessions spin up instantly on demand to handle traffic spikes
36
+
-**Sandboxed execution**: Each session runs in a secure microVM environment with resource controls
37
+
38
+
While session routing is valuable for multi-turn production agents, RL rollouts typically run as single invocations. However, the other properties—**session isolation**, **auto-scaling**, and **sandboxed execution**—still make ACR particularly well-suited for **online RL training**, which requires running many parallel agent rollouts with tool uses securely and efficiently. ACR handles the infrastructure complexity while you focus on agent logic and reward design. After training, you can deploy your fine-tuned model on the same ACR stack with minimal code changes—enabling a fast path from experimentation to production.
39
+
40
+
### Key Features
41
+
42
+
-**Minimal migration effort**: Convert your production agent to RL-ready with a simple decorator change (`@app.entrypoint` → `@app.rollout_entrypoint`)
43
+
-**Framework support**: Built-in support for Strands framework with extensible architecture for other frameworks
-**Production-ready**: Direct code reuse from production agents ensures training reflects real deployment behavior
47
+
48
+
### Starting Point: A Deployment-Ready Agent
49
+
50
+
This section shows what a deployment-ready ACR agent looks like—use it as a reference if you're new to ACR, or skip ahead if you already have a production agent. The agent must conform to [ACR's HTTP contract](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-http-protocol-contract.html) (endpoints like `/invocations`, `/ping`), but [`BedrockAgentCoreApp`](https://aws.github.io/bedrock-agentcore-starter-toolkit/user-guide/runtime/overview.html) handles this for you.
51
+
52
+
For Strands agents, see the [Deploy to Bedrock AgentCore guide](https://strandsagents.com/latest/documentation/docs/user-guide/deploy/deploy_to_bedrock_agentcore/python/). For other frameworks, see the [ACR Getting Started documentation](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/runtime-getting-started.html).
53
+
54
+
A minimal Strands agent looks like (see [`basic_app.py`](examples/strands_math_agent/basic_app.py) for full example):
55
+
56
+
```python
57
+
from bedrock_agentcore.runtime import BedrockAgentCoreApp
58
+
from strands import Agent
59
+
from strands.models import BedrockModel
60
+
61
+
app = BedrockAgentCoreApp()
62
+
model = BedrockModel(model_id="us.anthropic.claude-sonnet-4-20250514-v1:0")
Starting from a deployment-ready agent like above, here are the changes needed for RL training (see [`rl_app.py`](examples/strands_math_agent/rl_app.py) for full example):
77
+
```python
78
+
from agentcore_rl_toolkit import StrandsAgentCoreRLApp, StrandsRolloutCollector
1.**Prompt submission**: Training engine submits N prompts to ACR, which auto-scales to spin up N parallel agent sessions
142
+
2.**Agent execution**: Each agent session processes its prompt, calling the inference server for model responses
143
+
3.**Rollout collection**: Agents save rollouts and rewards to S3, send notifications via SQS
144
+
4.**Policy update**: Training engine polls SQS, collects rollouts from S3, and updates the model
145
+
146
+
This architecture enables parallel and highly efficient rollouts with secure execution during RL training. The decoupled design means training libraries only need the agent's container image to start training—agent code and dependencies stay completely separate from the training library.
147
+
148
+
### Supported Training Libraries
149
+
150
+
AgentCore runtime is currently supported by:
151
+
-**[veRL](https://github.com/volcengine/verl)**: See the integration [PR](https://github.com/volcengine/verl/pull/4216).
152
+
153
+
### Prepare Your Agent Container
154
+
155
+
ACR deploys agents as Docker containers. Most Dockerfiles can be auto-generated with the [AgentCore CLI](https://aws.github.io/bedrock-agentcore-starter-toolkit/api-reference/cli.html). Example command:
You can further customize these files if needed. Pre-generated Dockerfiles for all examples are provided in `.bedrock_agentcore/`. Once you have a Dockerfile, follow these steps to build and push your agent image to ECR.
Then, go to the training library of your choice and simply provide agentcore specific config args to start training.
42
-
43
-
44
-
## Development
189
+
### Start Training with veRL
45
190
46
-
### Installation
47
-
48
-
This project uses [uv](https://docs.astral.sh/uv/) for dependency management. Install uv if you haven't already, follow the installation [guide](https://docs.astral.sh/uv/getting-started/installation/#standalone-installer) here.
49
-
50
-
### For Package Development
51
-
52
-
If you're developing or contributing to the `agentcore-rl-toolkit` package itself:
191
+
Once your container is pushed to ECR, configure veRL with the AgentCore-specific parameters:
Additionally, when co-developing the toolkit together with examples, add the following to the example app's docker file so that changes to the toolkit is reflected in the container.
201
+
| Parameter | Description |
202
+
|-----------|-------------|
203
+
|`agent_name`| Name for your agent in ACR |
204
+
|`container_uri`| ECR URI of your RL-ready agent container |
205
+
|`s3_bucket`| S3 bucket for storing rollout data |
70
206
71
-
```bash
72
-
COPY ..
73
-
RUN uv pip install --force-reinstall --no-deps .
74
-
```
75
-
76
-
### For Running Examples
77
-
78
-
Each example has its own dependencies and can be installed independently. Follow the README for specific examples there (e.g., `examples/strands_math_agent/README.md`).
207
+
For a complete example, see the [veRL AgentCore integration PR](https://github.com/volcengine/verl/pull/4216).
79
208
80
-
## Appendix
209
+
## Contributing
81
210
82
-
### Prepare Docker file
211
+
We welcome contributions!
83
212
84
-
Docker file for most examples can be automatically generated with the `agentcore` CLI. Use `examples/strands_math_agent` as an example:
0 commit comments