Skip to main content

RL environment abstraction for Strands agents — step, observe, reward.

Project description

strands-env

RL environments for Strands agents — step, observe, reward.

strands-agents is designed for serving, not training. strands-env integrates strands-sglang to 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

strands_env-0.1.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

strands_env-0.1.0-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

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

Hashes for strands_env-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d1cb4f82995ad3e2a3d8bb37ab78f2cb362b1dccada26d7ed4274375673aa42e
MD5 5557fc4454266a785ca4b64ca06f4b6a
BLAKE2b-256 d7912dbf6ff185a16da2b5a0c2e217dfed39c176646bc6d25beeabd31f0b0c18

See more details on using hashes here.

Provenance

The following attestation bundles were made for strands_env-0.1.0.tar.gz:

Publisher: publish.yml on horizon-rl/strands-env

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for strands_env-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ade36a0e1cc10a786597a68a19bf118037a3046637f01ccb129801c3d2d74f08
MD5 c83f852a31d81ae8cb3629e1858005c9
BLAKE2b-256 7e09afa48b3a1552d3dea75d2e6a53a5feff1536974eaf82e015c609b8c8733c

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page