A framework for building agent environments with Strands Agents.
Project description
strands-env
A framework for building agent environments for RL training and evaluation with Strands Agents.
Features
An agent environment takes a task and runs the agent to completion over multiple turns, producing a rollout result — the trajectory, reward, and termination reason for that task. With strands-env, you can:
- Define Environments — Subclass
Environment, add@toolfunctions, plug inRewardFunction; typedTasksubclasses carry per-sample fields - RL Training — Token-level trajectories (TITO) for on-policy training with strands-sglang
- Benchmarking — CLI and
Evaluatorwith checkpointing, resume, and custom metrics
Install
pip install strands-env
For development:
git clone https://github.com/horizon-rl/strands-env.git && cd strands-env
pip install -e ".[dev]"
Quick Start
Define an Environment
Subclass Environment and add tools as @tool-decorated functions:
import subprocess
import sys
from strands import tool
from strands_env.core import Environment
@tool
def run_python(code: str) -> str:
"""Run a Python snippet and return its output."""
proc = subprocess.run([sys.executable, "-c", code], capture_output=True, text=True, timeout=10)
return proc.stdout + proc.stderr
class CodingEnv(Environment):
def get_tools(self):
return [run_python]
Run It
from strands_env.core import Task
env = CodingEnv(model_factory=factory, reward_fn=reward_fn)
result = await env.rollout(Task(
message="Write Python to compute the 10th Fibonacci number, then run it.",
ground_truth="55",
))
result.rollout # Rollout(token_ids=..., loss_mask=..., ...); token-level rollout if using SGLang backend
result.final_response # "The 10th Fibonacci number is 55"
result.reward_result # {"reward": 1.0, "info": ...}
result.termination_reason # TerminationReason.TASK_COMPLETE
See the examples/ directory for complete, runnable demos.
Run Evaluations
python -m strands_env.eval \
--benchmark terminal-bench-2 \
--env examples.eval.terminal_bench.terminal_bench_env \
--backend sglang \
--base-url http://localhost:30000 \
--n-samples-per-prompt 4 \
--max-concurrency 8
Raise
--n-samples-per-promptfor more stable pass@k, and--max-concurrencyif you're using a hosted sandbox service.
Tip: For a non-agentic benchmark (no tool use), don't override
get_tools()— the base class returns[]by default.
Built-in Environments
Ready-to-use environments under src/strands_env/environments/. Each ships with its own README, system prompt, and requirements.txt.
| Environment | Description |
|---|---|
calculator |
Calculator tool with symbolic-equivalence reward for math reasoning. |
agentcore_code |
Python / shell execution via AWS Bedrock AgentCore Code Interpreter. |
web_search |
Google search + Jina page scraping with optional LLM summarization, enlightened by OpenSeeker. |
harbor |
Run Harbor-format tasks in sandboxes. Supports training like SETA and evaluation like Terminal-Bench and SWE-bench. |
tau2_bench |
tau2-bench customer-service dialogues (airline/retail/telecom) driven by an LLM user-simulator. |
mcp_atlas |
MCP-Atlas benchmark runner across 36 MCP servers with 500 tasks. |
agent_world_model |
AgentWorldModel tasks with 1000 synthetic FastAPI + SQLite environments exposed as MCP tools. |
Documentation
- Evaluation Guide — CLI reference, hook files, custom evaluators
- RL Training Integration — integration with the slime RL training framework
Development
# Lint
ruff check src/ && ruff format --check src/
# Unit tests
pytest tests/unit/ -v
# Integration tests (requires running SGLang server)
pytest tests/integration/ -v --sglang-base-url=http://localhost:30000
Or if using Claude Code, just use /run-unit-tests and /run-integration-tests slash commands.
License
Apache License 2.0 — see LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file strands_env-0.6.1.tar.gz.
File metadata
- Download URL: strands_env-0.6.1.tar.gz
- Upload date:
- Size: 163.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69f2f9e38b3191a8de9aeb1641be8c961b2dc426338cef858a05724a389dac15
|
|
| MD5 |
6c0b9b11a7b6eee2e2f60b6e8f8b00e2
|
|
| BLAKE2b-256 |
74584ecf70d6b3f743ff911aaf2e18c957e352f09e06a2241084bd50c9e9d71b
|
Provenance
The following attestation bundles were made for strands_env-0.6.1.tar.gz:
Publisher:
publish.yml on strands-rl/strands-env
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
strands_env-0.6.1.tar.gz -
Subject digest:
69f2f9e38b3191a8de9aeb1641be8c961b2dc426338cef858a05724a389dac15 - Sigstore transparency entry: 2092139043
- Sigstore integration time:
-
Permalink:
strands-rl/strands-env@88d837052c0423a281265d7203f761377af1b47c -
Branch / Tag:
refs/tags/v0.6.1 - Owner: https://github.com/strands-rl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@88d837052c0423a281265d7203f761377af1b47c -
Trigger Event:
release
-
Statement type:
File details
Details for the file strands_env-0.6.1-py3-none-any.whl.
File metadata
- Download URL: strands_env-0.6.1-py3-none-any.whl
- Upload date:
- Size: 160.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce4bb8f8cc142945d8d2e0f9c84d0c2b09af2958fa4c7404be72fde5ee6a299e
|
|
| MD5 |
e07c991e8439224d6e43f67ca2a7e4b4
|
|
| BLAKE2b-256 |
7b794c9c6d13066c016b031b6bc60893936ba17a51d41b006c675fedc5b90a37
|
Provenance
The following attestation bundles were made for strands_env-0.6.1-py3-none-any.whl:
Publisher:
publish.yml on strands-rl/strands-env
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
strands_env-0.6.1-py3-none-any.whl -
Subject digest:
ce4bb8f8cc142945d8d2e0f9c84d0c2b09af2958fa4c7404be72fde5ee6a299e - Sigstore transparency entry: 2092139406
- Sigstore integration time:
-
Permalink:
strands-rl/strands-env@88d837052c0423a281265d7203f761377af1b47c -
Branch / Tag:
refs/tags/v0.6.1 - Owner: https://github.com/strands-rl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@88d837052c0423a281265d7203f761377af1b47c -
Trigger Event:
release
-
Statement type: