Examples
Example: code-generation agent
An agent that edits a repository to make a task's tests pass. The hidden tests are the scorer, and every task has a cost.
What it registers
| Kind | Name | What |
|---|---|---|
| action | read_file | path → contents. |
| action | apply_patch | diff → applied or the error. |
| action | run_tests | Runs the visible tests: selector → results. |
| scorer | hidden_pass | 1 if the hidden tests pass after the agent finishes, else 0. |
| dataset | tasks-v3 | 180 tasks (repo snapshot, issue text, hidden tests), in your registry. |
| runner | runner | docker run --rm agent-eval --variant {variant} --tier {tier} --task {task} |
How it's scored
hidden_pass (pass@1, bar 0.45). The agent sees only the visible tests; the hidden ones decide. Each run reports cost_usd from token usage and seconds, and the experiment caps spend with max_cost_usd. Inside the run, a meter refuses calls that would cross the cap.
The code
from synaptra_sdk import Harness
from synaptra_sdk.meter import Meter, BudgetExceeded
h = Harness.connect("code-agent", url="https://synaptra.my", token=TOKEN)
def run_task(variant: str, tier: str, task: dict, experiment_id: int) -> dict:
with Meter(experiment_id=experiment_id) as m:
try:
result = agent.solve(task, variant=variant, budget=m) # m.allow / m.charge_tokens inside
status = "ok"
except BudgetExceeded:
result, status = None, "invalid"
passed = float(result is not None and hidden_tests(task, result.workdir).passed)
return {"task": task["id"], "variant": variant, "tier": tier, "status": status,
"metrics": {"hidden_pass": passed}, "seconds": result.seconds if result else None}
rows = [run_task("plan-then-edit", "T1", t, 57) for t in dev_tasks]
h.report(rows, experiment_id=57)import { BudgetExceeded, Harness, Meter } from "synaptra-sdk";
const h = await Harness.connect("code-agent", { url: "https://synaptra.my", token: TOKEN });
async function runTask(variant: string, tier: string, task: Task, experimentId: number) {
let result: Result | null = null;
let status = "ok";
{
await using m = await Meter.open({ experimentId });
try {
result = await agent.solve(task, { variant, budget: m }); // m.allow / m.chargeTokens inside
} catch (e) {
if (!(e instanceof BudgetExceeded)) throw e;
status = "invalid";
}
}
const passed = Number(result !== null && (await hiddenTests(task, result.workdir)).passed);
return { task: task.id, variant, tier, status, metrics: { hidden_pass: passed }, seconds: result?.seconds };
}
const rows = [];
for (const t of devTasks) rows.push(await runTask("plan-then-edit", "T1", t, 57));
await h.report(rows, { experimentId: 57 });A first experiment
e = h.propose(
"Plan before editing", "plan-then-edit",
{"T0": {"pass_rate": 1}, "T1": {"mean_hidden_pass": 0.5, "cost_usd": 9}},
hypothesis="Failed tasks edit the wrong file first",
treatment_axes=["prompt"],
max_cost_usd=12,
)const e = await h.propose({
title: "Plan before editing",
variant: "plan-then-edit",
hypothesis: "Failed tasks edit the wrong file first",
predictions: { T0: { pass_rate: 1 }, T1: { mean_hidden_pass: 0.5, cost_usd: 9 } },
treatmentAxes: ["prompt"],
maxCostUsd: 12,
});{"title": "Plan before editing", "variant": "plan-then-edit",
"hypothesis": "Failed tasks edit the wrong file first",
"treatment_axes": ["prompt"], "max_cost_usd": 12,
"predictions": {"T0": {"pass_rate": 1}, "T1": {"mean_hidden_pass": 0.5, "cost_usd": 9}}}What this won't tell you
- Whether the code is maintainable: passing tests is the bar, not code quality. Add a reviewer metric if that matters.
- Leakage: if tasks or their fixes are public, a model may have seen them. Keep some tasks private and recent.
- A budget-stopped run is
invalid, not a fail: it says the harness broke, not that the variant lost.
Something unclear or missing? Email support@synaptra.my.