Metadata-Version: 2.5
Name: agentplaykit
Version: 0.15.0
Summary: A model-agnostic simulation and benchmarking platform: build environments, connect AI agents, run experiments, and evaluate their intelligence, strategies and behaviour.
Project-URL: Homepage, https://github.com/thetejasmagade/agentplay
Project-URL: Documentation, https://agentplay.itejas.dev/
Project-URL: Changelog, https://github.com/thetejasmagade/agentplay/blob/master/CHANGELOG.md
Project-URL: Issues, https://github.com/thetejasmagade/agentplay/issues
Author: AgentPlay contributors
License-Expression: MIT
License-File: LICENSE
Keywords: agents,ai,benchmark,evaluation,llm,multi-agent,simulation
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.8
Requires-Dist: jsonschema>=4.18
Requires-Dist: pyyaml>=6.0
Provides-Extra: anthropic
Requires-Dist: anthropic; extra == 'anthropic'
Provides-Extra: dev
Requires-Dist: mypy>=1.10; extra == 'dev'
Requires-Dist: pre-commit; extra == 'dev'
Requires-Dist: pytest-cov>=5; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Requires-Dist: types-jsonschema; extra == 'dev'
Requires-Dist: types-pyyaml; extra == 'dev'
Provides-Extra: docs
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
Requires-Dist: mkdocs>=1.6; extra == 'docs'
Provides-Extra: hf
Requires-Dist: huggingface-hub>=0.34; (python_version >= '3.9') and extra == 'hf'
Requires-Dist: safetensors>=0.4; (python_version >= '3.9') and extra == 'hf'
Requires-Dist: transformers>=4.56; (python_version >= '3.9') and extra == 'hf'
Provides-Extra: mcp
Requires-Dist: mcp>=1.2; (python_version >= '3.10') and extra == 'mcp'
Description-Content-Type: text/markdown

<p align="center">
  <img src="docs/assets/logo.svg" alt="AgentPlay logo" width="120" height="120">
</p>

<h1 align="center">AgentPlay</h1>

<p align="center"><strong>Build environments. Connect any AI. Measure what it does.</strong></p>

**A model-agnostic simulation and benchmarking platform that allows developers to build environments, connect AI agents, run experiments, and evaluate their intelligence, strategies, and behaviour.**

MIT-licensed and written in Python. Any model can play (hosted, local or your own program), every run is logged and replayable, and results come with ratings and confidence intervals.

**Status:** released on PyPI as [`agentplaykit`](https://pypi.org/project/agentplaykit/). Docs: <https://agentplay.itejas.dev>. The specs in [`specs/`](specs/) are the source of truth; every requirement has a test.

## Install
Python 3.8 or newer. Plain `pip` works:
```bash
pip install agentplaykit
pip install -e ".[dev]"             # from a clone, for development
```

## Try it
```bash
pip install agentplaykit
agentplaykit play                                  # built-in demo, no API key needed
agentplaykit play examples/guess/scenario.yaml     # a custom world + agent from plain .py files
agentplaykit play examples/tic-tac-toe-chat/scenario.yaml   # two agents play tic-tac-toe and chat
agentplaykit check examples/guess/scenario.yaml    # validate without running
agentplaykit view runs/tic-tac-toe-demo-7.jsonl      # replay a run in your browser
agentplaykit play examples/tic-tac-toe-chat/scenario.yaml --live   # watch it live
agentplaykit env list                              # available worlds
agentplaykit doctor                                # check your setup
```
Every move, message and cost lands in a JSONL log under `runs/`.

A scenario is one YAML file; swap an agent by changing its `use` line:
```yaml
agentplay: 1
name: tic-tac-toe-demo
seed: 7
world: {use: tic-tac-toe}
agents:
  - {id: x, use: scripted/minimax}
  - {id: o, use: scripted/random}
```
A new world (`examples/guess/guess_world.py`) is under 50 lines and a new agent (`bisect_agent.py`) under 30, with no framework changes.

## Experiments
Run many scenarios, agents, settings and seeds from one file, in parallel and resumable, then compare them in one report:
```bash
agentplaykit experiment plan examples/experiment/tic-tac-toe.yaml    # cells, runs, cost estimate
agentplaykit experiment run examples/experiment/tic-tac-toe.yaml --workers 4
agentplaykit report runs/tic-tac-toe-players
```
See the [experiments guide](https://agentplay.itejas.dev/guides/experiments/).

## Benchmarks
Score any agent on a fixed, versioned suite: one number from 0 (the baseline) to 1 (the reference), with a 95% range, that anyone can check against the logs:
```bash
agentplaykit bench run agentplay-basics --agent '{use: ollama, config: {model: "qwen2.5:3b"}}'
agentplaykit bench verify runs/agentplay-basics-1.0.0/qwen2.5-3b/submission.json
agentplaykit bench board runs/agentplay-basics-1.0.0/*/submission.json --out board
```
See the [benchmarks guide](https://agentplay.itejas.dev/guides/benchmarks/).

Something went wrong? Every error ends with a code such as `[provider.rate_limited]`; look it up on the [Troubleshooting page](https://agentplay.itejas.dev/troubleshooting/).

## Build your own
```bash
agentplaykit new world auction        # a working world, scenario and test to start from
agentplaykit test auction/auction_world.py --sloppy   # how it copes with small-model mistakes
```
[World helpers](https://agentplay.itejas.dev/guides/world-helpers/) (`TurnBased`, `TextMoves`, `ChoiceMoves`) make most worlds a few dozen lines, and [wrappers](https://agentplay.itejas.dev/guides/wrappers/) add memory, instructions or format hints to any agent with `wrap: [memory, format_hints]`.

## Example: two AI models debate
[`examples/debate`](examples/debate) has qwen2.5 and llama3.2 arguing "I'm better than you", with the models on a free Google Colab GPU and the debate watched live in your browser. The [step-by-step guide](https://agentplay.itejas.dev/tutorials/debate/) and the [Colab notebook](https://colab.research.google.com/github/thetejasmagade/agentplay/blob/master/examples/debate/debate_colab.ipynb) cover both setups: models on Colab with AgentPlay on your computer, or everything inside Colab.

## Use real AI models
Any model can play, hosted or local. Change the agent's `use` line:

| `use` | Connects to |
|---|---|
| `openai`, `openrouter`, `groq`, `deepseek`, `gemini`, `mistral`, `together` | That hosted service; only `model` is needed, the key comes from its usual variable (`OPENROUTER_API_KEY`, ...) |
| `ollama` | A local Ollama server: free, no key |
| `huggingface` | Open models on the Hugging Face Hub through Inference Providers (key: `HF_TOKEN`) |
| `transformers` | Hugging Face models running on your own CPU or GPU, no server (`pip install "agentplaykit[hf]"` plus PyTorch) |
| `chat_api` | Any other chat API in the OpenAI-compatible format (DigitalOcean, Cloudflare AI Gateway, LM Studio, vLLM, llama.cpp, proxies) via `base_url` |
| `anthropic` | Claude via the Anthropic SDK (`pip install "agentplaykit[anthropic]"`) |
| `command` | Any program, in any language, reading and writing JSON lines |
| `http` | Any agent behind a URL |
| `mcp` | A tool on an MCP server (`pip install "agentplaykit[mcp]"`, Python 3.10+) |

```yaml
- {id: x, use: ollama, config: {model: "llama3.2"}}                 # local, free
- {id: y, use: openrouter, config: {model: "<provider>/<model>"}}   # key from OPENROUTER_API_KEY
```
Keys come from environment variables, never from the scenario.
Every call's tokens and cost are logged; runs stop at `max_cost_usd` (default $1). Set `price`
per model for exact costs (`openrouter` reports its own). See `examples/tic-tac-toe-llm/scenario.yaml` and `examples/command-agent/`.

## Score and compare
Add evaluators to a scenario; they read only the finished log, so agents can never touch them:
```yaml
evaluators:
  - {use: outcome, config: {agent: x}}                 # did x win?
  - {use: judge, config: {rubric: "Did x explain its moves?", agent: {use: openrouter, config: {...}}}}
```
Run many seeds and get a summary (pass rate, steps, cost, spread):
```bash
agentplaykit play examples/treasure/scenario.yaml --runs 20
```
Rank agents against each other: a tournament plays every pairing on both sides, and a report
gives a leaderboard with ratings, ranges, costs and errors:
```bash
agentplaykit play examples/arena/scenario.yaml   # tournament + report
agentplaykit report runs/                        # a report from any logs
```
Give an agent a real task in a locked-down container (no network, non-root, caps), checked
afterwards by commands it never sees (needs Docker):
```bash
agentplaykit play examples/hello-sandbox/scenario.yaml
```
Check your own world or agent against the specs before sharing it:
```bash
agentplaykit test my_world.py
agentplaykit test my_agent.py --world tic-tac-toe
```

## Vision and roadmap
AgentPlay is built around four pillars: **build environments**, **connect AI agents**, **run experiments** and **evaluate intelligence, strategies and behaviour**, all model-agnostic.

| Pillar | Available now | Next |
| --- | --- | --- |
| Environments | World interface and helpers, `agentplaykit new`, plugins, test kit with sloppy models; tic-tac-toe, rock-paper-scissors, chess with scripted opponents at three levels, debate, negotiation, sandbox (Docker) | No-code world templates; reuse Gymnasium, PettingZoo and OpenSpiel environments |
| Agents | Any OpenAI-compatible API, 9 presets, Anthropic, Hugging Face (hosted and local), any program; wrappers for memory, instructions and format hints; constrained output and `model check` for small models | Images for vision models; adapters for agent frameworks |
| Experiments | Seeds, `--runs`, tournaments, budgets, live view, replays; experiment files: sweeps in parallel, resumable, one report | Workers on other machines |
| Evaluation | Outcomes, pass rates, Bradley–Terry ratings, judge behaviour tags; versioned benchmark suites with a combined score, verification and leaderboards; behaviour metrics; move-by-move strategy analysis with blunders (tic-tac-toe, chess) | Analysts for more worlds; strategy summaries in words |

The full roadmap is on the [docs site](https://agentplay.itejas.dev/roadmap/).

## Develop
```bash
python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"
pytest
```
(`uv` works too: `uv venv && uv pip install -e ".[dev]"`.)

See [CONTRIBUTING.md](CONTRIBUTING.md). Licensed under [MIT](LICENSE).
