Skip to content

AgentPlay: Development Plan (Spec-Driven, MIT)

Nov 29, 2026 · @Tejas

1. Vision and scope

AgentPlay v0.1 is an MIT-licensed Python framework for putting AI agents into worlds, letting them act and talk, and scoring and logging what happens. It is the engine only: no viewer, no hosted service, no marketplace. "AgentPlay" is the chosen name, but the PyPI name agentplay is already taken, so a distinct package name must be picked before the first release (decision 1).

Three goals the framework must serve

  1. Evaluate models fairly: identical world, rules, seeds and limits for every agent, scored by code outside the agent.
  2. Observe behavior: agents can message each other, and every move and message lands in one replayable log.
  3. Be easy to extend: a new world in under 50 lines, a new agent in under 30, with no framework changes.

In scope for v0.1

  • Environment interface with multi-agent support and per-agent observations
  • Agent interface plus adapters: Claude API, OpenAI-compatible (covers OpenRouter and local servers), MCP, scripted bots
  • Message bus between agents
  • Scenario file (YAML) with a versioned schema, loader and validator
  • Runner: turn order, step, time and cost limits, illegal-move handling
  • Registry for worlds and agents (local, global, built-in lookup)
  • Structured JSONL run log with token and cost tracking
  • Evaluator hooks: code checkers now, a slot for judge models later
  • Reference worlds: tic-tac-toe and one blank world
  • CLI: play, check, env list, doctor

Out of scope for v0.1 (the log and interfaces must leave room for them)

  • Viewer, visual views and replays in a browser
  • Docker sandbox and browser/web-testing worlds
  • Minecraft and other external-world adapters
  • Leaderboards, reports, SaaS, accounts, billing
  • Natural-language scenario builder

v0.1 is done when

  • A new world is added in under 50 lines and a new agent in under 30, without touching framework code.
  • The same scenario runs with a scripted bot and with a real model by changing one line.
  • Two agents finish a tic-tac-toe game while chatting, and moves, messages and cost are all in the log.
  • A fresh machine goes from pip install to a finished demo run in under 2 minutes, with no API key.

2. Principles and the spec-driven workflow

In this project the spec is the source of truth and code is its implementation: no feature is built until its spec is accepted, and a mismatch between code and spec is a bug in one of them.

Design principles

  • Small core, plugins at the edges. Worlds, agents, evaluators and adapters are plugins; the core stays tiny.
  • Plain data across every boundary. Observations, actions, messages and logs are JSON-serializable, so any language or tool can read them.
  • The log is the product. Everything a viewer, evaluator or report needs must be in the log; nothing is recomputed by rerunning.
  • Deterministic by default. Every run takes a seed and records versions, so results can be reproduced.
  • Fail loudly, with the fix. Errors name the file, field and next step; no raw stack traces for user mistakes.
  • Cheap and safe by default. Step, time and cost caps are on from the first run; secrets never reach logs; heavy dependencies are optional extras.

How a change moves through the workflow

  1. Propose. Open an issue describing the problem and the user-visible behavior wanted.
  2. Write the spec. A numbered Markdown spec in specs/ using MUST, SHOULD and MAY (RFC 2119), with numbered requirements and acceptance criteria. Machine-readable parts (scenario schema, log schema) are JSON Schema files in specs/schemas/.
  3. Review and accept. A spec PR needs one maintainer approval and a 3-day comment window for anything that changes a public interface. Status moves Draft, Accepted, Implemented, Deprecated.
  4. Write conformance tests first. Each requirement gets a test ID (for example ENV-012) in tests/conformance/. Tests fail until the feature exists.
  5. Implement. The PR links the spec and the test IDs it satisfies; CI blocks the merge if a linked test fails.
  6. Release. A spec change that breaks compatibility bumps the schema version and adds a migration note. Specs ship in the repo and are rendered as the docs site.

Rules that keep it honest

  • Spec changes and code changes land in separate commits, so history shows which drove which.
  • Pydantic models for the scenario and log are generated from or validated against the JSON Schemas, never hand-written twice.
  • Every public function or field in the code traces to a spec section; unspecified public API is not allowed.
  • Small fixes that do not change behavior (typos, refactors, docs) skip the spec step.

3. Architecture and repository layout

The core knows only two interfaces, one for worlds and one for agents, so any agent plugin works with any world plugin.

[embedded content: architecture · 3 plugin areas, 1 core, 1 log]

The core loads a scenario, runs the turns, relays messages and writes the log. Evaluators, and later viewers, read only the log, which is why the log format is frozen first.

Proposed repository layout

agentplay/
  LICENSE  README.md  CONTRIBUTING.md  CODE_OF_CONDUCT.md
  SECURITY.md  GOVERNANCE.md  MAINTAINERS.md  CHANGELOG.md
  pyproject.toml
  specs/                 numbered specs and JSON Schemas
    schemas/             scenario.schema.json, runlog.schema.json
  src/agentplay/
    core/                interfaces, runner, message bus, log writer
    scenario/            loader and validation
    registry/            @register, plugin discovery
    agents/              claude, openai_compat, mcp, scripted
    envs/                tic-tac-toe, blank, simultaneous
    evals/               checker interface, multi-run summary
    cli/                 play, check, env list, doctor
  tests/                 conformance, schema, golden, fixtures
  examples/              runnable scenarios
  docs/                  guides and adr/
  .github/               CI, issue forms, PR template

Package boundaries (enforced in CI)

  • core imports nothing from agents, envs or evals; plugins import only the core interfaces. An import-boundary check fails the build otherwise.
  • Worlds, agents and evaluators register through entry-point groups (agentplay.envs, agentplay.agents, agentplay.evaluators), so third-party packages plug in without changes to this repo.
  • Provider SDKs are imported only inside their own adapter and installed as optional extras (agentplay[claude], [openai], [mcp]).
  • Only core writes the log; plugins return plain data and never touch files.
  • Core runtime dependencies stay minimal: the standard library plus a schema validator and a YAML parser.

4. Spec catalog

Twelve specs cover v0.1; write the log, environment and agent specs first because everything else depends on them. Each spec gets an ID, a status and a numbered requirement list.

Spec Defines Milestone
SPEC-000 Process Spec format, RFC 2119 keywords, statuses, change flow, versioning policy M0
SPEC-001 Environment reset, observe(agent), actions(agent), step(agent, action), multi-agent turn semantics, done and error results M1
SPEC-002 Agent act() contract, capabilities (tool calls, vision, JSON mode), retries and fallbacks M1
SPEC-003 Run log JSONL event types, required fields, seed and version metadata, redaction rules, JSON Schema M1
SPEC-004 Runner Episode lifecycle, turn order (sequential and simultaneous), step, time and cost limits, forfeits, provider-error handling M1
SPEC-005 Scenario YAML schema (agentplay: 1), single-file and split layouts, path and name resolution order, defaults M2
SPEC-006 Registry @register, lookup order (local, global, built-in), plugin entry points, name collisions M2
SPEC-007 CLI Commands, flags, exit codes, error message format, doctor checks M2
SPEC-008 Message bus say(to, text), public and private messages, ordering, size limits, logging M3
SPEC-009 Adapters Claude API, OpenAI-compatible (OpenRouter, local), MCP, scripted bots; usage and cost reporting; key handling M4
SPEC-010 Evaluators Checker interface, result schema, judge-model slot, independence rule (agent cannot touch the checker) M5
SPEC-011 Security Secrets policy, log redaction, plugin trust model, sandbox hooks for later phases M0, extended M6

Each spec file follows one template: purpose, terms, numbered requirements, acceptance criteria mapped to test IDs, examples, open questions, and a change log.

5. Milestones

Seven milestones take the project from an empty repo to a tagged v0.1.0 in about 11 weeks, assuming one full-time developer working with Claude Code. Each milestone starts with its specs accepted and ends only when its exit criteria pass in CI.

M0 · Foundation (week 1)

  • Create the repo, MIT LICENSE, pyproject.toml, package skeleton, lint, type check, test runner and pre-commit hooks.
  • Add CI (tests on Linux, macOS, Windows; Python 3.10 to 3.13).
  • Add specs/ with the template, SPEC-000 (process) and a draft SPEC-011 (security).
  • Add community files: CONTRIBUTING, CODE_OF_CONDUCT, SECURITY, issue and PR templates, docs/adr/ for decisions.
  • Exit: CI is green on the empty package, and SPEC-000 itself merged through the workflow it describes.

M1 · Core (weeks 2 to 3)

  • Accept SPEC-001 to SPEC-004; publish the run-log JSON Schema.
  • Build the Environment and Agent base classes, the log writer and a sequential-turn runner.
  • Ship the tic-tac-toe world and two scripted agents (random, minimax) as reference implementations.
  • Exit: a tic-tac-toe run writes a log that validates against the schema; a golden-log test pins the format; the runner enforces step limits and forfeits after repeated illegal moves.

M2 · Scenarios, registry, CLI (weeks 4 to 5)

  • Accept SPEC-005 to SPEC-007.
  • Build the YAML loader and validator, reference resolution (path, then local name, then global, then built-in), the registry and @register.
  • Add the CLI commands play, check, env list, and a blank-world template.
  • Exit: a documented example adds a new world in under 50 lines; agentplay check reports missing files and bad fields with the fix, pinned by error-message tests.

M3 · Multi-agent and messaging (week 6)

  • Accept SPEC-008.
  • Add per-agent observations, simultaneous-turn mode and the message bus with public and private messages.
  • Add the two-agent tic-tac-toe scenario with chat between moves.
  • Exit: with a fixed seed, the log holds the same interleaved moves and messages every run; message size limits and ordering are covered by tests.

M4 · Real agents and cost control (weeks 7 to 8)

  • Accept SPEC-009.
  • Build adapters for the Claude API, OpenAI-compatible endpoints (OpenRouter, local servers) and MCP, with capability flags and a plain-text fallback for models without tool calls.
  • Add token and cost accounting, budget caps, retries and rate-limit handling; provider errors are logged separately from model failures.
  • Record API responses as test fixtures so CI needs no keys or network.
  • Exit: one scenario runs with a scripted bot and with a real model by changing one line; a budget cap stops a run and marks the log budget_exceeded.

M5 · Evaluation (week 9)

  • Accept SPEC-010.
  • Build the checker interface and result schema, a --runs N command with a summary (pass rate, steps, cost, spread), the judge-model slot (interface and one example), and agentplay doctor.
  • Exit: a 20-run summary can be reproduced from its seeds; a checker cannot read or change agent-side state.

M6 · Hardening and release (weeks 10 to 11)

  • Build the docs site from the specs; write the quickstart and the "write a world" and "write an agent" tutorials; add an examples/ folder (tic-tac-toe chat, blank world, treasure hunt).
  • Run a security review of secrets handling, log redaction and plugin loading.
  • Check package-name availability, publish to PyPI, tag v0.1.0 and write release notes.
  • Exit: every "done when" criterion in section 1 passes on a clean Linux, macOS and Windows machine.

6. Testing and quality strategy

Every spec requirement has at least one test, and CI is the gate: a change that fails a linked test or breaks a schema cannot merge. No test may need a network connection or an API key.

Test layers

Layer What it proves Example
Conformance Code meets a numbered spec requirement ENV-012: step with an illegal action returns an error and does not change state
Schema Logs and scenarios validate against JSON Schema Every log written by the test suite passes the log schema
Golden log The log format does not drift silently A seeded tic-tac-toe game must reproduce a stored log byte for byte
Property-based Rules hold for any input Random action sequences never leave tic-tac-toe in an invalid state
Adapter fixtures Adapters parse real provider responses Recorded Claude and OpenRouter replies replayed offline
Error messages Mistakes produce a clear fix Missing file, unknown world and bad field each match a stored message
End-to-end The quickstart works Fresh virtualenv, install, agentplay play demo finishes

Quality gates in CI

  • Linux, macOS and Windows; Python 3.10 to 3.13.
  • Lint, format check and strict type check on the core package.
  • Coverage floor of 90% on core/, reported but not enforced on examples.
  • Spec-link check: every public symbol cites a spec section, and every requirement ID has a test.
  • Dependency and license scan, so nothing incompatible with MIT enters.

Conformance kit for plugin authors

The repo ships a test kit that a third-party world or agent runs against itself (agentplay test my_world.py). It checks the interface contract, determinism under a seed and log validity, so community plugins meet the same bar as the built-ins.

7. Open-source setup

The project ships under the MIT license from the first commit, with the community files, contribution flow and release process in place before the first outside contributor arrives.

License

  • LICENSE holds the standard MIT text with "Copyright (c) 2026 AgentPlay contributors" (replace with the owner's legal name if preferred).
  • Every source file starts with # SPDX-License-Identifier: MIT; CI fails if one is missing.
  • Contributors keep their copyright and license their work under MIT (inbound equals outbound). Use a Developer Certificate of Origin sign-off (Signed-off-by) rather than a CLA, enforced by a bot.
  • CI scans dependencies and rejects licenses that are incompatible with MIT.
  • Examples, docs and specs are covered by the same license, so people can copy them freely.

Files in the repo root

File Purpose
LICENSE MIT text
README.md One-paragraph pitch, the 60-second quickstart, links to specs and docs
CONTRIBUTING.md Dev setup, spec-first workflow, DCO sign-off, how to run tests
CODE_OF_CONDUCT.md Contributor Covenant, with a contact address
SECURITY.md Private reporting through GitHub security advisories; reply within 3 days; supported versions
GOVERNANCE.md How decisions and spec acceptance work; how to become a maintainer
MAINTAINERS.md and CODEOWNERS Review ownership; specs/ always needs a maintainer
CHANGELOG.md Keep a Changelog format, one entry per release
.github/ Issue forms (bug, world request, spec proposal), PR template with spec and test links, CI workflows

Governance

  • Start with a single lead maintainer who accepts specs; add maintainers once someone has landed several accepted specs and reviews.
  • Public interface changes need an accepted spec and a 3-day comment window; everything else follows normal review.
  • Record significant decisions as short ADRs in docs/adr/.

Contribution flow

  1. Open an issue, or pick one labelled good first issue or world-request.
  2. If behavior changes, a spec PR comes first.
  3. Implementation PR links the spec and test IDs, passes CI and carries DCO sign-off.
  4. Plugins and worlds outside the core live in their own repos and list themselves in a community/ index, so the core stays small.

Releases

  • Semantic versioning; 0.x until the interfaces settle, with the scenario and log schemas versioned independently (agentplay: 1).
  • GitHub Actions builds and publishes to PyPI using trusted publishing (no long-lived tokens), with signed tags and release notes drawn from the changelog.
  • Docs are built from specs/ and docs/ with MkDocs and published on GitHub Pages.
  • Community starts on GitHub Discussions; add chat only when traffic justifies it.

MIT carries no explicit patent grant. That is acceptable for this project; revisit if companies contribute and ask for one.

8. Risks and mitigations

The biggest risk is freezing the wrong interface early; the rest are manageable with limits, fixtures and clear scope.

Risk Why it matters Mitigation
Wrong core interface (multi-agent, per-agent views) Every world and adapter depends on it Prove it with three worlds before 0.1: tic-tac-toe, blank, and a small simultaneous-move game such as rock-paper-scissors; stay on 0.x versions; require spec review
Log format drifts Viewers, evaluators and old runs break JSON Schema with a version, golden-log tests, migration notes
Runaway token cost Surprise bills for users and contributors Caps on by default, cost in every log, recorded fixtures so CI is free
Provider differences and silent changes (tool calls, routed models on OpenRouter) Unfair or unreproducible comparisons Capability flags, plain-text fallback, log the model and provider each response reports, date every run
LLM non-determinism Identical configs give different results Define reproducibility as same config and seed; use multi-run statistics, not single runs
Untrusted plugin code A shared world or agent runs with the user's privileges Trust notice on first load, agentplay check never imports code, security spec, sandbox hooks reserved for later
Spec process too heavy Slows a small project and discourages contributors Short template, specs only for behavior changes, 3-day review window
Scope creep into viewer, sandbox, SaaS v0.1 never ships Fixed out-of-scope list; later phases tracked in the roadmap, not the milestones
Name or trademark clash Forced rename after release Check package, domain and trademark databases in M0
Single-maintainer bottleneck Reviews stall ADRs, good first issue labels, add maintainers early

9. After v0.1, and decisions still open

Each later release adds one capability on top of the frozen log and interfaces, and each follows the same spec-first workflow.

Roadmap after v0.1 (order may change with user feedback)

  1. v0.2 Viewer: a local web viewer and replay driven only by the run log, with declarative grid and board views.
  2. v0.3 Sandbox: offline Docker worlds (for example the hello.txt task), network off, resource caps, outside checkers.
  3. v0.4 Browser world: a Playwright-based web-testing environment with domain allowlists and evidence capture.
  4. v0.5 Reports and judging: comparison reports, an Elo-style head-to-head rating, judge-model behavior tags (cooperated, deceived, gave up).
  5. v0.6 External worlds: HTTP /observe and /step adapter, then Minecraft through Mineflayer.
  6. Later: plain-English scenario builder, shareable world packs, then a hosted service with bring-your-own-key runs, teams and CI integration.

Open decisions (recommendation first; settle each in an ADR during M0)

  1. Name and package name. Keep "AgentPlay" as the display name, but the PyPI name agentplay is already taken, so choose a distinct package and import name before the first release (a suffixed package name, or a close variant such as Agentplaybox), and check domain and GitHub availability. Identifiers in this plan use agentplay as a placeholder until then.
  2. Default turn model. Sequential, with simultaneous turns as an opt-in per world.
  3. Core language. Python for the core, with schemas kept language-neutral so other implementations are possible later.
  4. Tooling. uv for environments, ruff for lint and format, pytest, and a strict type checker.
  5. First release scope. Local only, no accounts or hosting.
  6. Behavior judging. Interface in v0.1; the judge implementation waits for v0.5.
  7. Minimum Python version. 3.10, to match common agent tooling.
  8. License holder. Decide whether the copyright line names a person, an organization or "contributors".
  9. Hosting of docs and community. GitHub Pages and GitHub Discussions at first.