RL environment abstraction for Strands agents — step, observe, reward.
Project description
strands-env
RL environments for Strands agents — step, observe, reward.
strands-agentsis designed for serving, not training.strands-envintegratesstrands-sglangto bridge this gap.
Define an environment
Subclass Environment and customize your tools:
from strands_tools import calculator
from strands_env.core.environment import Environment
class MathEnv(Environment):
def get_tools(self):
return [calculator]
Run it
env = MathEnv(model_factory=factory, reward_fn=reward_fn)
result = await env.step(Action(message="What is 2^10?", task_context=TaskContext(ground_truth="1024")))
result.observation.final_response # "1024"
result.observation.tokens # TokenObservation (SGLang only, for on-policy RL training)
result.reward.reward # 1.0
result.termination_reason # task_complete
Each step() runs a full agent loop (reasoning + tool calls), not a single model call. Strands' hook-based design makes it easy to customize what happens within each step.
Install
pip install strands-env
For development:
git clone <repo-url> && cd strands-env
pip install -e ".[dev]"
See examples/math_env.py for a complete runnable example:
python examples/math_env.py --backend sglang --sglang-base-url http://localhost:30000
python examples/math_env.py --backend bedrock --model-id us.anthropic.claude-sonnet-4-20250514
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
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.1.0.tar.gz.
File metadata
- Download URL: strands_env-0.1.0.tar.gz
- Upload date:
- Size: 22.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d1cb4f82995ad3e2a3d8bb37ab78f2cb362b1dccada26d7ed4274375673aa42e
|
|
| MD5 |
5557fc4454266a785ca4b64ca06f4b6a
|
|
| BLAKE2b-256 |
d7912dbf6ff185a16da2b5a0c2e217dfed39c176646bc6d25beeabd31f0b0c18
|
Provenance
The following attestation bundles were made for strands_env-0.1.0.tar.gz:
Publisher:
publish.yml on horizon-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.1.0.tar.gz -
Subject digest:
d1cb4f82995ad3e2a3d8bb37ab78f2cb362b1dccada26d7ed4274375673aa42e - Sigstore transparency entry: 908069225
- Sigstore integration time:
-
Permalink:
horizon-rl/strands-env@442ec1c11afc6e199465bc72f25b83adae0867cb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/horizon-rl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@442ec1c11afc6e199465bc72f25b83adae0867cb -
Trigger Event:
release
-
Statement type:
File details
Details for the file strands_env-0.1.0-py3-none-any.whl.
File metadata
- Download URL: strands_env-0.1.0-py3-none-any.whl
- Upload date:
- Size: 14.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ade36a0e1cc10a786597a68a19bf118037a3046637f01ccb129801c3d2d74f08
|
|
| MD5 |
c83f852a31d81ae8cb3629e1858005c9
|
|
| BLAKE2b-256 |
7e09afa48b3a1552d3dea75d2e6a53a5feff1536974eaf82e015c609b8c8733c
|
Provenance
The following attestation bundles were made for strands_env-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on horizon-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.1.0-py3-none-any.whl -
Subject digest:
ade36a0e1cc10a786597a68a19bf118037a3046637f01ccb129801c3d2d74f08 - Sigstore transparency entry: 908069227
- Sigstore integration time:
-
Permalink:
horizon-rl/strands-env@442ec1c11afc6e199465bc72f25b83adae0867cb -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/horizon-rl
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@442ec1c11afc6e199465bc72f25b83adae0867cb -
Trigger Event:
release
-
Statement type: