Sample 01 · Coding & agentic
Terminal-Bench task
A self-contained task in the Terminal-Bench format: a short instruction, a reproducible environment, a reference solution and automated tests that decide pass or fail. This one is an original example written for this page.
A command-line tool at /app/dedupe.py should read a CSV of customer
records and write a copy without duplicate rows. Two rows are duplicates
when their email addresses match, ignoring case and surrounding spaces.
The tool currently crashes on files with a UTF-8 byte-order mark and keeps
the wrong row when duplicates appear.
Fix /app/dedupe.py so that:
1. python /app/dedupe.py in.csv out.csv succeeds on BOM and non-BOM files;
2. for each duplicate group, the row with the latest "updated_at" is kept;
3. the original column order and header are preserved.FROM python:3.12-slim
WORKDIR /app
COPY dedupe.py data/ /app/
# No network access during the run; tests are copied in only at grading time.def test_keeps_latest_row(tmp_path):
out = run_tool("data/dupes.csv", tmp_path / "out.csv")
rows = read_rows(out)
assert [r["email"] for r in rows] == ["ana@example.com", "li@example.com"]
assert rows[0]["updated_at"] == "2026-03-02T10:00:00Z"
def test_handles_bom(tmp_path):
out = run_tool("data/with_bom.csv", tmp_path / "out.csv")
assert read_header(out) == ["id", "email", "name", "updated_at"]What we check before delivery
- The reference solution passes every test; the untouched starting code fails them
- Tests check behaviour, not one exact implementation
- No answer leaks in the instruction, file names or environment
- Hardened against shortcuts such as hard-coding the expected output
- Runs offline, deterministically, with pinned versions
- Difficulty checked against agent runs before submission