Skip to main content

Standardizing environment infrastructure with Strands Agents — step, observe, reward.

Project description

strands-env

CI PyPI License

Standardizing environment infrastructure with Strands Agents — step, observe, reward.

Features

This package treats each env.step() as a full agent loop (prompt → (tool_call, tool_response)* → response), not a single model call.

  • Define Environments — Subclass Environment, add @tool functions, plug in RewardFunction
  • RL Training — Token-level observations for on-policy training with strands-sglang
  • Benchmarking — CLI and Evaluator with 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:

from strands import tool
from strands_env.core import Environment

@tool
def calculator(expression: str) -> str:
    """Evaluate a math expression."""
    return str(eval(expression))

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   # "The answer is 1024"
result.reward.reward                # 1.0
result.termination_reason           # TerminationReason.TASK_COMPLETE

See examples/calculator_demo.py for a complete example.

Run Evaluations

strands-env eval aime-2024 \
    --env examples/envs/calculator_env.py \
    --backend sglang \
    --base-url http://localhost:30000 \
    --n-samples-per-prompt 8 \
    --max-concurrency 30

Documentation

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.2.tar.gz (46.4 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.2-py3-none-any.whl (43.6 kB view details)

Uploaded Python 3

File details

Details for the file strands_env-0.1.2.tar.gz.

File metadata

  • Download URL: strands_env-0.1.2.tar.gz
  • Upload date:
  • Size: 46.4 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.2.tar.gz
Algorithm Hash digest
SHA256 eed6df0b0167c1c7a74b8bf2611a6cd77625eb164b584c7684b1e978e9e455a8
MD5 66abc1ba51d21166bfb2e74ca6c909e8
BLAKE2b-256 b238e94cb98afd83a4b8f3c7be9695a3de57e8ea5bf8d866065c764f4117fd86

See more details on using hashes here.

Provenance

The following attestation bundles were made for strands_env-0.1.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: strands_env-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 43.6 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 b68b87137a831fd1fa6c6f28392295e77219ce206f919e8e97b5f5282a7a9456
MD5 454562a7f2a4ff2aca2dff4cb78902a4
BLAKE2b-256 7439262e6515864e8b1ce4bab84bb5f3fb2ab7264d2fd38ca5d54f01f565f9ea

See more details on using hashes here.

Provenance

The following attestation bundles were made for strands_env-0.1.2-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