Designing Verifiable Agent Environments
To turn a raw artifact pool (repos, documents, systems) into scalable, verifiable training environments:
- Define an environment tuple:
e = (I, W, V, O)— Instructions/spec, Workspace, Verifier, Oracle. - Define a multiplicative objective
Q = A · C · Scombining:A(Validity): binary gate — oracle passes, blank baseline fails.C(Coupling/complexity): structural interdependency proxy (e.g., normalized propagation cost over a call graph).S(Scope): size/breadth proxy (e.g.,log(LOC) + log(1+dependencies)).
- Build an Evolution Loop: an agent inspects current
(A, C, S), decides what to revise (spec, oracle, tests), re-measures, and keeps only strictly-improving, still-valid revisions — all without running the trainee model. - Scale by running this loop over thousands of candidates under a fixed per-candidate budget (e.g., ≤12 rounds).
Progress:
- Step 1: Source and filter raw candidates
- Step 2: Reconstruct verifiable runtime per candidate
- Step 3: Extract structural evidence (static analysis)
- Step 4: Synthesize task spec + verifier from evidence
- Step 5: Define the multiplicative proxy objective
- Step 6: Run Evolution Loop (repair → optimize) under budget
- Step 7: Validate scaling via ablations and dataset statistics
Step 1: Source and Filter Candidates
Apply cheap static filters before expensive processing:
- Recency / provenance (exclude benchmark-contaminated items)
- Minimum signal of testability (has a manifest, has ≥1 test)
- Size bounds (not trivial, not unbounded — e.g., ≥5 files, <40k LOC)
- Isolation feasibility (no required network/GUI/hardware, or mockable)
Step 2: Reconstruct Verifiable Runtime
For each candidate, in an isolated sandbox:
- Build/install, resolve runtime issues (agent-assisted repair loop allowed here)
- Require ALL tests pass in a fresh, resource-bounded, network-isolated container
- Archive the validated image + exact install/test commands
- Discard only after exhausting construction budget — don't discard on first failure
Step 3: Extract Structural Evidence
Use read-only static analysis (AST scan) to extract:
- Public interface surface (classes/functions/signatures/exceptions)
- Symbols actually imported by tests (ground truth for "what must exist")
- Implementation call graph (excluding tests) for coupling computation
- Dependency manifest for scope computation
Step 4: Synthesize Task Spec + Verifier
- Generate a natural-language task spec from evidence (never from the solution code directly — agent must not see oracle during solving)
- Generate an API manifest documenting required interfaces
- Critical check: cross-reference spec/manifest against symbols the hidden tests actually import. Missing symbols → send back to synthesis agent for revision. This prevents "functionally correct but wrong interface name" failures.
- Materialize final environment: isolated workspace + hidden verifier + hidden oracle.
Step 5: Define the Multiplicative Objective
Design proxies that are:
- Cheap: computable via static analysis or oracle execution alone — never require running the trainee agent.
- Multiplicative, not additive: force all dimensions to be simultaneously non-degenerate (a zero in any factor zeroes the whole score; additive scores let one strong dimension mask a collapsed one).
- Gated by validity first: optimize complexity/scope only after
A=1; otherwise you optimize a broken task.
Example instantiation (adapt proxy formulas to your domain):
A = 1 if oracle_passes and blank_baseline_fails else 0
C = reachable_ordered_pairs / N^2 # structural coupling via call graph
S = log10(LOC) + log10(1 + num_deps) - c # implementation scope
Q = A * C * S
Step 6: Run the Evolution Loop
for candidate in valid_candidates:
for round in range(max_rounds):
if A == 0:
agent.repair(using=validation_report, execution_trace)
else:
weak_dim = argmin(C/threshold_C, S/threshold_S)
revision = agent.revise(oracle, spec, tests, target=weak_dim)
A', C', S' = recompute(revision)
if A' == 1 and score(weak_dim') > score(weak_dim):
accept(revision)
else:
reject(revision) # roll back
Key design choices:
- Revise oracle, spec, and tests jointly — not just the spec (keeps them consistent).
- Strict-improvement acceptance criterion with rollback prevents drift/degradation.
- Fixed round budget (not convergence-based) bounds cost per candidate.
- No trainee-model rollouts anywhere in this loop — that's the core cost-saving move.
Step 7: Validate at Scale
Before declaring success, report:
- Diversity (domain/category histogram — check no category >15-20% dominance)
- Scale distributions (LOC, file count, verifier/test density) with percentiles
- Difficulty vs. success-rate correlation (bin by proxy score, measure teacher success rate — should anti-correlate, confirming proxy validity)
- Environment-count scaling curve (downstream metric vs. number of environments — look for continued gains, not early saturation)
- Ablate each proxy term independently (hold others fixed, vary one, measure downstream training effect)
Example 1:
Input: A GitHub repo with 8 files, passing tests, but trivial complexity (one flat utility module).
Output: Evolution Loop flags S below threshold → agent adds a realistic submodule structure with cross-file dependencies to the oracle, updates spec to describe the expanded functionality, updates tests to cover new interfaces, re-validates A=1, confirms S increased → revision accepted.
Example 2:
Input: A candidate repo fails to build in the sandbox due to a missing system library pinned incorrectly in the manifest.
Output: Repair step uses the build error trace to patch the dependency manifest/Dockerfile, retries build+test, achieves A=1 within 2 of the 3 allotted repair attempts — candidate recovered instead of discarded.
Example 3:
Input: Task spec describes a JsonParser class, but hidden tests import from pkg.parsing import JsonParser.
Output: Coverage check detects the missing symbol/import-path mismatch, flags it for the synthesis agent, which updates the spec/API manifest to name the class and path explicitly before materialization.
- Gate before you optimize. Never spend optimization budget on structurally invalid environments.
- Keep the oracle, spec, and verifier mutually consistent on every revision — treat them as one atomic unit, not three independent artifacts.
- Prefer proxies computable without running the trainee agent. Any feedback loop requiring full rollouts amplifies cost on long-horizon tasks; reserve expensive rollouts for final data collection, not iterative construction.
- Use strict-improvement + rollback, not best-effort acceptance — this prevents proxy-gaming revisions that regress other dimensions.
- Derive specs/tests from evidence extraction, not free generation — grounding in real interfaces/tests prevents spec-implementation drift.
- Bound every loop with a fixed budget (time, rounds, or compute) — unbounded optimization loops don't scale to thousands of candidates.
- Measure correlation between your proxy and actual task difficulty/success rate before trusting it as a training-value signal.
- Discarding on first failure. Rigid linear pipelines that drop any non-conforming candidate waste reusable raw material — always attempt bounded repair first.
- Using additive objectives for multi-dimensional quality. Additive scores let one dominant term compensate for a collapsed one (e.g., huge LOC masking zero coupling); use multiplicative when all dimensions must be jointly healthy.
- Optimizing task difficulty via model rollouts during construction. This is the main scalability trap — it ties construction cost and latency to solver inference cost, which explodes for long-horizon tasks.
- Letting the spec-writing agent see the oracle solution directly without constraining it to evidence extraction — leads to leakage or inconsistency between what's described and what's actually tested.
- Skipping the symbol-coverage cross-check between spec and hidden tests — produces environments where correct solutions fail purely due to interface-naming mismatches, polluting your reward signal.
- Declaring scale success from raw environment count alone — always pair count with diversity, difficulty-correlation, and downstream scaling-curve evidence.