Toolkit for Seamlessly Enabling RL Training on Any Agent with Bedrock AgentCore.
- Main package:
agentcore-rl-toolkitis a thin wrapper around of bedrock-agentcore-sdk-python that allows developers to start RL training their production agent with only a few lines of code change. - Examples: Located in
examples/directory, each with their ownpyproject.tomland dependencies. Their corresponding docker files are located in.bedrock_agentcore, most of which have been generated automatically (see instructions below).
AgentCore runtime is currently supported by the following training library.
Before training, build the docker for the RL-ready application and upload to ECR. To do this, follow the steps below:
First, make sure aws sts get-caller-identity returns the right identity. If not, follow the developer guide to set up AWS Credentials. After setup, run aws sts get-caller-identity again to verify.
Next, the build script requires info related to your AWS account. Create a .env file from the example:
cp .env.example .envThen edit .env and fill in your values:
AWS_REGION: Your AWS region (e.g.,us-west-2)AWS_ACCOUNT: Your AWS account IDECR_REPO_NAME: Your ECR repository name
# Use examples/strands_math_agent as an example
chmod +x scripts/build_docker_image_and_push_to_ecr.sh
bash ./scripts/build_docker_image_and_push_to_ecr.sh --dockerfile=.bedrock_agentcore/examples_strands_math_agent_rl_app/Dockerfile --tag=devThen, go to the training library of your choice and simply provide agentcore specific config args to start training.
This project uses uv for dependency management. Install uv if you haven't already, follow the installation guide here.
If you're developing or contributing to the agentcore-rl-toolkit package itself:
# Enter the repository
cd agentcore-rl-toolkit
# Create and activate uv environment
uv venv --python 3.13
source .venv/bin/activate
# Install with development dependencies
uv sync --frozen --extra dev
# Install pre-commit hooks
pre-commit installAdditionally, 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.
COPY . .
RUN uv pip install --force-reinstall --no-deps .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).
Docker file for most examples can be automatically generated with the agentcore CLI. Use examples/strands_math_agent as an example:
agentcore configure --entrypoint examples/strands_math_agent/rl_app.py --requirements-file examples/strands_math_agent/pyproject.toml --deployment-type container --disable-memory --non-interactiveMake sure to run the command in project root.
See CONTRIBUTING for more information.
This project is licensed under the Apache-2.0 License.