Skip to content

Commit 23bf2a7

Browse files
authored
doc: improve doc for the math agent example (#5)
1 parent b8f8a31 commit 23bf2a7

6 files changed

Lines changed: 268 additions & 85 deletions

File tree

AGENTS.md

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ uv run pytest tests/
3535

3636
# Build and push Docker image to ECR (current approach, may change)
3737
./scripts/build_docker_image_and_push_to_ecr.sh \
38-
--dockerfile=.bedrock_agentcore/examples_strands_math_agent_rl_app/Dockerfile \
38+
--dockerfile=examples/strands_math_agent/.bedrock_agentcore/strands_math_agent_rl/Dockerfile \
3939
--tag=latest
4040

4141
# Run example locally
@@ -52,7 +52,6 @@ cd examples/strands_math_agent && uv sync && uv run python rl_app.py
5252
| `src/agentcore_rl_toolkit/batch_runner.py` | `BatchRunner` for parallel evaluation |
5353
| `src/agentcore_rl_toolkit/reward_function.py` | `RewardFunction` base class |
5454
| `examples/strands_math_agent/` | GSM8K math agent example |
55-
| `examples/strands_migration_agent/` | Code migration agent with evaluation example |
5655

5756
---
5857

@@ -73,23 +72,15 @@ agentcore-rl-toolkit/
7372
│ └── rollout_collector.py # StrandsRolloutCollector
7473
├── examples/
7574
│ ├── strands_math_agent/ # GSM8K example
75+
│ │ ├── .bedrock_agentcore/ # Dockerfiles for deployment
7676
│ │ ├── basic_app.py # Production agent
7777
│ │ ├── rl_app.py # RL-adapted agent
7878
│ │ ├── reward.py # GSM8KReward implementation
7979
│ │ └── pyproject.toml # Example-specific dependencies
80-
│ └── strands_migration_agent/ # Code migration example
81-
│ ├── basic_app.py
82-
│ ├── rl_app.py
83-
│ ├── evaluate.py # BatchRunner usage example
84-
│ └── ...
8580
├── tests/
8681
│ └── test_rollout_entrypoint.py
8782
├── scripts/
8883
│ └── build_docker_image_and_push_to_ecr.sh
89-
├── .bedrock_agentcore/ # Generated Dockerfiles per agent
90-
│ ├── examples_strands_math_agent_rl_app/Dockerfile
91-
│ └── examples_strands_migration_agent_rl_app/Dockerfile
92-
├── .bedrock_agentcore.yaml # Agent configurations
9384
├── pyproject.toml
9485
└── uv.lock
9586
```
@@ -292,18 +283,16 @@ This package relies on [bedrock-agentcore-starter-toolkit](https://github.com/aw
292283
- We prioritize container (ECR image) deployment for operational simplicity
293284

294285
**Current workflow:**
295-
1. Dockerfiles are generated in `.bedrock_agentcore/{agent_name}/Dockerfile`
296-
2. Use `scripts/build_docker_image_and_push_to_ecr.sh` to build and push (this approach may change when starter-toolkit is upgraded):
286+
1. Dockerfiles are generated in `examples/{agent_name}/.bedrock_agentcore/{app_name}/Dockerfile`
287+
2. Use `scripts/build_docker_image_and_push_to_ecr.sh` to build and push:
297288
```bash
298289
./scripts/build_docker_image_and_push_to_ecr.sh \
299-
--dockerfile=.bedrock_agentcore/examples_strands_math_agent_rl_app/Dockerfile \
290+
--dockerfile=examples/strands_math_agent/.bedrock_agentcore/strands_math_agent_rl/Dockerfile \
300291
--tag=latest
301292
```
302293
3. Training engine takes ECR URI as config for deployment
303294
4. Environment variables (model inference address, model name, etc.) are injected by the training engine
304295

305-
**Note:** When co-developing the package with examples, Docker images are built at project root with custom install steps to reflect library changes.
306-
307296
### Evaluation
308297

309298
Users can evaluate agents before and after training using the same `rl_app.py`.
@@ -313,8 +302,6 @@ Users can evaluate agents before and after training using the same `rl_app.py`.
313302
- **Concurrency control**: Manages ACR session limits (1000/account) and model API rate limits
314303
- **SQS-based completion**: Polls until all results are received
315304

316-
Example usage: `examples/strands_migration_agent/evaluate.py`
317-
318305
**Note:** `create_openai_compatible_model()` accepts `provider_model_id` to call hosted cloud models (for evaluation) instead of training cluster inference servers.
319306

320307
---
@@ -359,12 +346,10 @@ uv run pytest tests/
359346

360347
### Building and Pushing Docker Images
361348

362-
**Note:** This approach may change when starter-toolkit is upgraded.
363-
364349
```bash
365350
# Ensure .env is configured with AWS_REGION, AWS_ACCOUNT, ECR_REPO_NAME
366351
./scripts/build_docker_image_and_push_to_ecr.sh \
367-
--dockerfile=.bedrock_agentcore/examples_strands_math_agent_rl_app/Dockerfile \
352+
--dockerfile=examples/strands_math_agent/.bedrock_agentcore/strands_math_agent_rl/Dockerfile \
368353
--tag=my-tag
369354
```
370355

@@ -440,9 +425,6 @@ uv run pre-commit install
440425

441426
### Dependency Updates
442427
- **bedrock-agentcore-starter-toolkit**: Needs upgrade to latest version for better Docker utilities and local testing support
443-
- Build context will change (Dockerfiles move to example folders)
444-
- Custom install steps for co-development may need updating
445-
- Current `scripts/build_docker_image_and_push_to_ecr.sh` approach may be replaced
446428

447429
---
448430

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ AgentCore runtime is currently supported by:
155155
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:
156156

157157
```bash
158-
# Run from project root
159-
agentcore configure --entrypoint examples/strands_math_agent/rl_app.py \
160-
--requirements-file examples/strands_math_agent/pyproject.toml \
158+
# Run from examples/strands_math_agent
159+
agentcore configure --entrypoint rl_app.py \
160+
--requirements-file pyproject.toml \
161161
--deployment-type container --disable-memory --non-interactive
162162
```
163163

164-
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.
164+
You can further customize these Dockerfiles if needed. Once you have a Dockerfile, follow these steps to build and push your agent image to ECR.
165165

166166
### Setup Credentials and Environment Variables
167167

@@ -183,7 +183,7 @@ Then edit `.env` and fill in your values:
183183
```bash
184184
# Use examples/strands_math_agent as an example
185185
chmod +x scripts/build_docker_image_and_push_to_ecr.sh
186-
bash ./scripts/build_docker_image_and_push_to_ecr.sh --dockerfile=.bedrock_agentcore/examples_strands_math_agent_rl_app/Dockerfile --tag=dev
186+
bash ./scripts/build_docker_image_and_push_to_ecr.sh --dockerfile=examples/strands_math_agent/.bedrock_agentcore/strands_math_agent_rl/Dockerfile --tag=dev
187187
```
188188

189189
### Start Training with veRL

.bedrock_agentcore/examples_strands_math_agent_basic_app/Dockerfile renamed to examples/strands_math_agent/.bedrock_agentcore/strands_math_agent_basic/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ ENV UV_SYSTEM_PYTHON=1 \
1212

1313

1414

15-
COPY examples/strands_math_agent examples/strands_math_agent
15+
COPY . .
1616
# Install from pyproject.toml directory
17-
RUN cd examples/strands_math_agent && uv pip install .
17+
RUN cd . && uv pip install .
1818

1919

2020

.bedrock_agentcore/examples_strands_math_agent_rl_app/Dockerfile renamed to examples/strands_math_agent/.bedrock_agentcore/strands_math_agent_rl/Dockerfile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,15 @@ ENV UV_SYSTEM_PYTHON=1 \
1212

1313

1414

15-
COPY examples/strands_math_agent examples/strands_math_agent
15+
COPY . .
1616
# Install from pyproject.toml directory
17-
RUN cd examples/strands_math_agent && uv pip install .
17+
RUN cd . && uv pip install .
1818

1919

2020

2121

2222
RUN uv pip install aws-opentelemetry-distro==0.12.2
2323

24-
# [TODO]: remove the following lines after being able to add this agentcore-rl-toolkit as
25-
# a dependency in examples/strands_math_agent/pyproject.toml
26-
COPY . .
27-
RUN uv pip install --force-reinstall --no-deps .
28-
2924

3025
# Signal that this is running in Docker for host binding logic
3126
ENV DOCKER_CONTAINER=1

0 commit comments

Comments
 (0)