Skip to main content

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

Project description

strands-env

Awesome Strands Agents

CI PyPI License Ask DeepWiki

A gym-like framework for building agent environments for RL training.

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

python -m strands_env.eval \
    --benchmark aime-2026 \
    --env examples.eval.simple_math.calculator_env \
    --backend sglang \
    --base-url http://localhost:30000 \
    --n-samples-per-prompt 8 \
    --max-concurrency 30

Tip: For a non-agentic benchmark (no tool use), simply don't override get_tools() in your environment — 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 Simple environment with a calculator tool for math reasoning.
harbor Run Harbor-format tasks in sandboxes. Supports training like SETA and evaluation like Terminal-Bench and SWE-bench.
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.
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

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


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.4.0.tar.gz (138.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.4.0-py3-none-any.whl (133.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: strands_env-0.4.0.tar.gz
  • Upload date:
  • Size: 138.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for strands_env-0.4.0.tar.gz
Algorithm Hash digest
SHA256 ccf6addd93be799ddeae6173464c542c15c6861107667d87c4e3fa998556bcf1
MD5 f486bb2b1bff2bcde2835a0e341b4f24
BLAKE2b-256 4beb4bf44cfba8c400368c9084a4ff33899a35b2562ac67b998f24c1d3d32b3f

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on strands-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.4.0-py3-none-any.whl.

File metadata

  • Download URL: strands_env-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 133.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for strands_env-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d57c828f2ba4cd2891762c5aaa9c0f48a37971a49c887f39dd49e22e47f6e9a3
MD5 437d51dd4ca130d49852a6a6acb06b9a
BLAKE2b-256 97b57834984e40fc91328ef99bd9c49af6a213501145548e9fa3eec5d2326f65

See more details on using hashes here.

Provenance

The following attestation bundles were made for strands_env-0.4.0-py3-none-any.whl:

Publisher: publish.yml on strands-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