Skip to content

SPEC-019: Experiments

  • Status: Implemented
  • Milestone: v0.10 "Experiments"
  • Owners: lead maintainer

1. Purpose

Run many games from one file: several scenarios, several agents, several settings, many seeds, in parallel, safely stoppable and resumable, with a cost estimate first and one report at the end. Today this takes a shell loop around play --runs, and an interrupted batch starts over.

2. Terms

Keywords MUST, SHOULD and MAY follow RFC 2119. - Experiment file: a YAML file that describes the whole grid. - Cell: one combination of scenario, setting values and seating of agents. - Run: one cell played with one seed; it writes one log, exactly like play. - Manifest: experiment.json, the experiment's record of every run and its state.

3. Requirements

The experiment file

  • EXP-001 An experiment file MUST have agentplay: 1, experiment (a name), scenarios (a list of scenario files, relative to the experiment file), seeds (a count N, meaning each scenario's own seed and the N-1 after it as in EVL-014, or a list of exact seeds) and MAY have:
  • entrants: named agents (name, use, config, wrap) to seat in the scenarios' roles;
  • seating: all (every seating of distinct entrants in the roles, as tournaments do, RPT-004), each (every entrant in every role against the scenario's own other agents), or fixed (the scenarios' own agents, the default);
  • vary: a map from a setting path (such as world.config.rounds or limits.max_illegal) to a list of values, crossed with each other;
  • limits: overrides applied to every scenario;
  • max_total_cost_usd for the whole experiment, and max_parallel_per_provider (EXP-005). It MUST validate against specs/schemas/experiment.schema.json.
  • EXP-002 agentplaykit check <experiment.yaml> MUST validate every cell's generated scenario, without running anything or importing plugin code (SCN-013), and report each problem with the cell it belongs to.

Planning and running

  • EXP-003 agentplaykit experiment plan <file> MUST print the cells, the number of runs, and a cost estimate without running: the upper bound from each run's max_cost_usd, and when prices are known, an expected cost from earlier logs of the same agents and worlds if there are any.
  • EXP-004 agentplaykit experiment run <file> [--out DIR] [--workers N] MUST play every run. Each run MUST behave exactly as play would for that scenario and seed: the same seeds (EVL-014), log format and evaluators. Logs go to <out>/<experiment>/<cell>/, where <cell> is a short readable label plus a hash of the cell's settings, so the path is stable.
  • EXP-005 With --workers N, runs MUST play in N separate processes, and every log MUST be identical to a one-worker run apart from timing fields. The runner MUST cap concurrent runs per hosted provider with max_parallel_per_provider (default 2) to avoid rate-limit storms, and SHOULD warn that each worker loads its own copy of a local transformers model.
  • EXP-006 max_total_cost_usd MUST stop the experiment from starting new runs once reached, as for tournaments (RPT-005); runs already playing finish, and the manifest records which runs were not played.
  • EXP-007 A failed run (world_error, aborted) MUST NOT stop the experiment unless --stop-on-error is given; it is recorded in the manifest with its error.

Resuming and records

  • EXP-008 The manifest MUST list every run with its cell, seed, log path and state (done, failed, not played). Running the same experiment again MUST skip runs whose log is complete and matches the cell's scenario hash, and replay the rest; Ctrl+C MUST leave the manifest and every finished log valid. --fresh starts over in a new folder.
  • EXP-009 The manifest MUST record what is needed to repeat the experiment: the experiment file's hash, every generated scenario's hash, entrant configs (redacted, SEC-002), the AgentPlay, Python and platform versions, and the model revisions the logs report (HFM-008).
  • EXP-010 Changing the experiment file in a way that changes a cell MUST make its earlier runs count as a different cell, never be mixed with the new ones.

Results

  • EXP-011 agentplaykit report <experiment folder> MUST work as for any folder of logs (RPT-008), and MUST add an experiment section: for each varied setting, each value's results per competitor (rating or pass rate with intervals, cost, steps), so the effect of a setting can be read directly.
  • EXP-012 agentplaykit experiment status <folder> MUST print progress from the manifest: runs done, failed and left, cost so far, and the most common errors.
  • EXP-013 The Python API MUST offer run_experiment(path, out=..., workers=...), returning the manifest as plain data.

4. Acceptance criteria

Requirement Test ID Notes
EXP-001..002 EXP-001, EXP-002 schema; seating modes; vary crossing; check reports per cell
EXP-003..007 EXP-003..EXP-007 plan output; identical logs with 1 and 3 workers (scripted agents); provider cap with a fake server; budget stop; failures continue
EXP-008..010 EXP-008..EXP-010 interrupt after k runs and resume; corrupted log replayed; edited cell not mixed
EXP-011..013 EXP-011..EXP-013 report section per varied setting; status; API

5. Examples

agentplay: 1
experiment: small-models-tic-tac-toe
scenarios: [examples/tic-tac-toe-llm/scenario.yaml]
entrants:
  - {name: qwen-3b, use: ollama, config: {model: "qwen2.5:3b"}}
  - {name: llama-3b, use: ollama, config: {model: "llama3.2:3b"}}
  - {name: qwen-3b+memory, use: ollama, config: {model: "qwen2.5:3b"}, wrap: [memory]}
  - {name: minimax, use: scripted/minimax}
seating: all
vary:
  limits.max_illegal: [3, 5]
seeds: 10
max_total_cost_usd: 0
agentplaykit experiment plan small-models.yaml
agentplaykit experiment run small-models.yaml --workers 4
agentplaykit experiment status runs/small-models-tic-tac-toe
agentplaykit report runs/small-models-tic-tac-toe

6. Open questions

  • Running workers on other machines (a queue), and on Colab.
  • Adaptive experiments that stop a cell early once its interval is narrow enough.

7. Change log

  • 2026-12-01: Initial draft.
  • 2026-12-01: Accepted by the lead maintainer for v0.10, with details settled while building: seeds as a count or exact seeds; max_total_cost_usd and max_parallel_per_provider as top-level keys; reports read an experiment's logs from its manifest (RPT-022); ADR-0011.
  • 2026-12-03: Implemented in v0.10.0; every requirement has a test.
  • 2026-12-04: An experiment refuses a human agent (SPEC-027 HUM-014).

Changes to other specs on acceptance

  • SPEC-007, new CLI-018: experiment plan|run|status, and check on experiment files.
  • SPEC-013, new RPT-022: reports read an experiment folder's logs from its manifest, and add the experiment section (EXP-011).
  • ADR-0011 on running workers as processes and on per-provider concurrency caps.