Common evaluation infrastructure for evolving/auto-research systems. Terrarium provides a standard way to define benchmark tasks and run any evolution system against them with controlled, measured evaluation budgets.
┌──────────┐ ┌────────────────────────────────────────┐
│ Runner │───────►│ EvalServer │
└──────────┘ │ (single budget choke point) │
│ │ │
│ │ server.evaluate() ◄── in-process │
▼ │ POST /evaluate ◄── HTTP (ext.) │
┌──────────┐ │ │
│ Adapter │───────►│ BudgetTracker ── task.eval_fn │
└──────────┘ └────────────────────────────────────────┘
Every adapter — in-process or external — goes through the same EvalServer. The server owns the budget counter and the eval function. Adapters cannot bypass or modify it.
- In-process adapters (GEPA, custom) call
server.evaluate(candidate)directly — no HTTP overhead. - External adapters (Claude Code, any subprocess) POST to
server.url/evaluate— budget enforced server-side.
gepa is included as a submodule, pinned to the feat/optimize-anything-omni
branch, which includes the ClaudeCodeAgentProposer agentic reflection
backend used in the agent ablation:
git clone https://github.com/gepa-ai/terrarium.git
cd terrarium
git submodule update --init gepa
pip install -e .To advance the submodule to the latest feat/optimize-anything-omni
branch tip (e.g. to pick up post-submission optimizer features), use
git submodule update --init --remote gepa. Note that the branch is
under active development, so the tip can change numbers vs. the paper;
the paper numbers were produced with cfef49e.
python -m terrarium circle_packing my_adapter.py --max-evals 100from terrarium import run
result = run("circle_packing", "my_adapter.py", max_evals=100)
print(f"Best score: {result.best_score}")
print(f"Evals used: {result.total_evals}")from terrarium import run
from terrarium.adapters.gepa import GEPAAdapter
adapter = GEPAAdapter(reflection_lm="openai/gpt-5")
result = run("circle_packing", adapter, max_evals=150)| Task | Type | Candidate | Description |
|---|---|---|---|
circle_packing |
single-task | code | Pack 26 circles in a unit square, maximize sum of radii |
optuna_blackbox |
single-task | code | Evolve code to minimize a blackbox objective function |
frontier_cs_algo_<id> |
single-task | program | Solve one Frontier-CS algorithmic problem (C++) |
cloudcast |
multi-task | code | Cross-cloud broadcast routing across 5 region configs |
cant_be_late |
generalization | code | Spot-instance scheduling under deadlines |
aime_math / aime_math_mini |
generalization | prompt | AIME math problem solving |
arc_agi |
generalization | code | ARC-AGI abstract reasoning agent |
finer |
generalization | prompt | XBRL US-GAAP tag classification (ACE FiNER) |
formula |
generalization | prompt | Financial-formula numeric QA (ACE Formula) |
livebench_math |
generalization | prompt | LiveBench math benchmark (stratified by subtask) |
needle_in_range |
single-task | code | Needle-in-haystack range search |
slot_machines |
single-task | code | Bandit-style stationary slot-machine search |
The agent-ablation results in our paper are produced by the optimize_anything
pipeline (adapter=optimize_anything) wrapping each base optimizer. Each task is run at a matched
budget of 4000 metric calls / $400 token cost. The three prompt-optimization
tasks use deterministic subsampling for reproducibility:
| Paper experiment | Task name | Split (train / val / test) | subsample_seed |
|---|---|---|---|
| FiNER (Fig. agent_vs_gepa) | finer |
100 / 100 / 150 | 0 |
| Formula (Fig. agent_vs_gepa) | formula |
100 / 100 / 150 | 0 |
| LiveBench-Math (Fig. agent_vs_gepa) | livebench_math |
100 / 100 / 168 (frozen) | n/a |
| Frontier-CS (Fig. agent_vs_gepa) | frontier_cs_algo_<id> for id ∈ {0, 4, 145, 162, 255} |
per-problem (single-task) | n/a |
A one-shot reproducer for the prompt-optimization rows lives at
scripts/reproduce_paper.sh:
bash scripts/reproduce_paper.sh # all 3 prompt-opt tasks, GEPA + GEPA-Agent
bash scripts/reproduce_paper.sh finer # one taskNotes:
- Both optimizers run under
adapter=optimize_anythingwithengine: gepainsideadapter.configs. The difference is the nested key that selects the reflection proposer:reflection.reflection_lm(LLM reflection) for plain GEPA,claude_code_agent.model(agentic reflection) for GEPA-Agent. Seescripts/reproduce_paper.shfor the exact configs payload. - The standalone
adapter=gepa/adapter=claude_codepaths still work but are deprecated (they emit aDeprecationWarning); the paper numbers come from theoptimize_anythingcomposition. livebench_mathrequires the optional dependency group:pip install -e .[livebench_math]. The upstream HF dataset (livebench/math) is downloaded on first use; setHF_HOMEif your default cache is read-only.
An adapter is any class with an evolve(task, server, max_evals) -> Result method. The server is a terrarium EvalServer — use server.evaluate() to score candidates.
Create a Python file that defines create_adapter():
# my_adapter.py
from terrarium.adapter import Result
from terrarium.budget import BudgetExhausted
class MyEvolver:
def evolve(self, task, server, max_evals):
"""
Args:
task: Task definition — use task.objective, task.background,
task.initial_candidate, task.train_set, task.test_set as needed.
server: EvalServer — the single eval + budget choke point.
- server.evaluate(candidate) -> (score, info)
- server.evaluate(candidate, example) -> (score, info)
- Raises BudgetExhausted when budget runs out.
max_evals: Total eval budget (informational; enforced by server).
"""
candidate = task.initial_candidate
best_candidate = candidate
best_score = float("-inf")
for i in range(max_evals):
try:
score, info = server.evaluate(candidate)
except BudgetExhausted:
break
if score > best_score:
best_score = score
best_candidate = candidate
# Your mutation/evolution logic here
candidate = self.improve(candidate, score, info)
return Result(best_candidate=best_candidate, best_score=best_score)
def improve(self, candidate, score, info):
# ... your evolution logic ...
return candidate
def create_adapter():
return MyEvolver()Then run:
python -m terrarium circle_packing my_adapter.py --max-evals 100Dataset tasks have examples in task.train_set. Pass them to server.evaluate():
class DatasetEvolver:
def evolve(self, task, server, max_evals):
candidate = task.initial_candidate
best_candidate, best_score = candidate, float("-inf")
for i in range(max_evals // len(task.train_set)):
scores = []
for example in task.train_set:
score, info = server.evaluate(candidate, example)
scores.append(score)
avg = sum(scores) / len(scores)
if avg > best_score:
best_score = avg
best_candidate = candidate
candidate = self.improve(candidate, scores)
return Result(best_candidate=best_candidate, best_score=best_score)terrarium/adapters/gepa.py— Uses GEPA'soptimize_anything. Callsserver.evaluate()(in-process, no HTTP).terrarium/adapters/claude_code.py— Launches Claude Code as a subprocess. Gives it a shell script that POSTs toserver.url(HTTP, budget enforced server-side).terrarium/adapters/meta_harness.py— Meta-Harness loop (arXiv:2603.28052): repeatedly spawns a Claude proposer that writes candidate files, then benchmarks each throughserver.evaluate(). Budget counter (max_evals,max_token_cost) shared with every other adapter; per-iteration proposer spend capped viaclaude --max-budget-usd.
For systems that run as external processes, use the HTTP endpoint. The runner already starts the server — your adapter just needs to tell the subprocess where to POST:
class ExternalSystemAdapter:
def evolve(self, task, server, max_evals):
# The server is already running (started by the runner).
# Tell your external system to POST to it:
#
# POST http://localhost:{port}/evaluate
# Body: {"candidate": "...", "example_id": "..."}
# Response: {"score": 1.23, "info": {...}, "budget": {...}}
# HTTP 429 when budget exhausted
run_my_system(eval_url=server.url, task_desc=task.background)
return Result(
best_candidate=server.best_candidate,
best_score=server.best_score,
total_evals=server.budget.used,
)Create a new file in terrarium/tasks/ and register it:
# terrarium/tasks/my_task.py
from terrarium.registry import register_task
from terrarium.task import Example, Task
DESCRIPTION = "What this task optimizes and how it's scored."
INITIAL_CANDIDATE = "The starting text (code, prompt, etc.) to evolve from."
def evaluate(candidate: str) -> tuple[float, dict]:
"""Score a candidate. Return (score, info_dict).
For dataset tasks, the signature is:
def evaluate(candidate: str, example: Example) -> tuple[float, dict]
"""
score = run_my_eval(candidate)
return score, {"score": score}
# For dataset tasks, also define train/test sets:
# train_set = [Example(id="1", inputs={"problem": "..."}, expected="answer"), ...]
# test_set = [...]
TASK = register_task(Task(
name="my_task",
objective="One-line objective for the evolution system.",
background=DESCRIPTION,
initial_candidate=INITIAL_CANDIDATE,
eval_fn=evaluate,
# train_set=train_set, # for dataset tasks
# test_set=test_set, # for dataset tasks
metadata={
"type": "single_task", # or "generalization"
"candidate_type": "code", # or "prompt"
},
))Then add the import to terrarium/tasks/__init__.py:
from terrarium.tasks import my_task # registers on import- Single-task (
train_set=None): One hard problem.evaluate(candidate)takes no example. E.g., circle packing, blackbox optimization. - Dataset / generalization (
train_set=[...]): Many related problems.evaluate(candidate, example)is called per-example. E.g., AIME math, ARC-AGI.
- Return
(score: float, info: dict). Higher score = better. - The
infodict should include diagnostic feedback that helps the evolution system improve (error messages, partial results, execution traces). - Keep eval functions deterministic when possible.
- Import heavy dependencies inside the function body to keep task registration fast.
In-process adapter (GEPA) External adapter (Claude Code)
│ │
│ server.evaluate(candidate) │ POST /evaluate {"candidate": "..."}
│ │
└──────────────┬──────────────────────┘
▼
┌─────────────────┐
│ EvalServer │ ◄── single choke point
│ │
│ budget.check() │ ◄── pre-check
│ task.eval_fn() │ ◄── actual eval
│ budget.record()│ ◄── count it
│ track best │ ◄── update leaderboard
└─────────────────┘
The BudgetTracker and EvalServer live in the terrarium process. The evolution system — whether it's a Python library running in-process or a subprocess communicating over HTTP — can only evaluate through this server. It cannot read, write, or reset the budget counter.
POST /evaluate — submit a candidate, get score (HTTP 429 when budget exhausted)
GET /status — check budget and best score
GET /task — get task description and initial candidate