Sandbox: Act, Fail, Check
An agent can suggest a fix, run a fix, or produce a checked result. These are three different things. This exercise shows the difference on a small faulty script.
What you’ll do: run a script that gives a plausible wrong answer, test an agent with and without an independent checker, and verify that the checker itself was not altered.
The data is synthetic. The exercise uses only Python’s standard library and needs no API key to run by hand.
Key terms
- Model — the language model that writes text and proposes actions.
- Tool — an action the model can request: read a file, run a command, search.
- Harness — the software around the model that manages tools, context, permissions and execution. OpenCode, Claude Code and GitHub Copilot are harnesses.
- Sandbox — a disposable environment that holds none of your files or credentials.
Files
Create a new empty folder and download these three files into it. Start your agent inside that folder only.
| File | Purpose |
|---|---|
samples.json |
Six synthetic measurements in two groups: one missing (null, e.g. failed well) and one genuine 0 |
analyse.py |
The faulty script |
check.py |
The independent checker |
Optional: run inside a disposable VM with Multipass
For stronger isolation than an empty folder, [Multipass](https://canonical.com/multipass/docs/latest/how-to-guides/install-multipass/) gives you a disposable Ubuntu VM with one command: ```sh multipass launch 24.04 --name physalia-sandbox --cpus 2 --memory 2G --disk 10G multipass transfer --recursive sandbox-demo physalia-sandbox:/home/ubuntu/sandbox-demo multipass shell physalia-sandbox ``` Do not mount your home directory, and put no credentials or private data in the VM. Stop it afterwards with `multipass stop physalia-sandbox`. > **Limits:** a VM keeps the agent away from your host files. It does not block network access, and it does not make an analysis correct.1. Run the faulty script
cat samples.json
python3 analyse.py
python3 check.py
shasum check.py
analyse.py writes summary.json and exits cleanly. check.py fails: analyse.py counted the missing control measurement (null) as zero, so the control mean is 8.0 (n=3) where it should be 12.0 (n=2).
Note the hash printed by shasum check.py — you will compare it after the agent runs.
Question: does a clean exit and an output file prove success?
2. Act without a checker, then with one
2a. Vague prompt (no checker)
First, ask your agent without mentioning check.py or the bug:
Run analyse.py on samples.json and tell me if summary.json looks right.
Watch what happens. Does the agent spot the null → 0 bug on its own, or does it report that summary.json was generated cleanly?
2b. Repair with an independent checker
Now give the agent the checker:
Repair analyse.py so that summary.json passes check.py. Use only the Python
standard library. Do not edit samples.json or check.py. Run check.py and report
its exit status and the files you changed.
Watch the tool calls, and read each command before you approve it. Notice the subtle trap in samples.json: T1 has a genuine 0 measurement, while C2 is null. A naive fix like if row["value"]: drops T1 and fails check.py; only if row["value"] is not None: passes.
After the agent finishes, confirm check.py was not modified:
shasum check.py
"Do not edit check.py" is only an instruction — the agent can still break it. Comparing the hash verifies it.
Stuck? Reference repair
Replace `analyse.py` with: ```python """Summarise group measurements from samples.json into summary.json.""" import json from pathlib import Path root = Path(__file__).resolve().parent rows = json.loads((root / "samples.json").read_text()) groups = {} for row in rows: if row["value"] is not None: groups.setdefault(row["group"], []).append(row["value"]) summary = {name: {"mean": sum(values) / len(values), "n": len(values)} for name, values in groups.items()} (root / "summary.json").write_text(json.dumps(summary, indent=2) + "\n") print("Wrote summary.json.") ``` Expected result: control mean `12.0` (`n=2`); treated mean `14.0` (`n=3`).3. Remove the deliverable
rm -- summary.json
python3 check.py
python3 analyse.py
python3 check.py
The first check fails because the file is missing. The second passes.
Question: can a confident answer replace a missing file?
4. Discuss
- Did the agent catch the bug in Step 2a without the checker?
- What could the agent have damaged in this folder?
- Why is
shasum check.pystronger than writing “do not edit check.py” in the prompt? - The checker tests one known fixture. What would you need before trusting a result on real data?
Reading
Harness-Bench (arXiv:2605.27922) compares agent harnesses across models on realistic workflows. Read Table 2 of version 1 and separate three things: completed work, process quality and resource use.