The Good Engineers · built during neatHack, 10-12 Oct 2026
Mend
Agents that fix themselves, and prove it.
Mend reads its own neatlogs traces, works out why it failed, patches its own code, and keeps
the fix only if a full re-run gets better. Otherwise it reverts.
5 self-repair rounds kept · 6 reverted by the gate-24% tokenslatest chain of 1 rounds: 29/29 → 29/29 tasks solved, 456,563 → 347,960 tokens (single runs)see every round →
How it works
A self-repair loop with a hard gate.
01Run
A worker agent fixes planted bugs in a real codebase: 29 tasks, judged by the test suite, not by the agent.
02Trace
Every model call and tool call is a span in neatlogs, with inputs, outputs, tokens and cost.
03Diagnose
A supervisor pulls failed and wasteful runs back over the neatlogs MCP server and finds the step that went wrong.
04Patch
Claude Code applies one general fix to the worker: never a task-specific hack, never the tests.
05Checkpoint
Entire links the commit to the session that wrote it, so every self-fix carries its reasoning.
06Prove
The whole suite re-runs. More tasks solved, or the same with 15% fewer tokens: kept. Anything else: reverted.
The first bug Mend found in itself
It was deleting the end of long files.
Reading its own neatlogs traces, the supervisor saw the worker read only the first 200 lines of a
233-line file, then rewrite the whole file to change one word. Everything after line 200 was
silently gone. The fix it wrote for itself: Add a targeted edit_file (exact string replace) tool and steer edits away from whole-file rewrites.
Before · task 23failedran out of turns at 15 · trace 1636ec5a
After · task 23passedin 8 turns · trace 78712d5b
Repeatable, not lucky
Same 28 tasks, run again and again.
The worker before its first self-repair against the worker after it, each run several times.
Mean tokens per run changed by -7.5%.
Before self-repair · 3 runs27, 26, 27 / 28mean 946,860 tokens per runtask 23 passed in 0 of 3 runs
After self-repair · 3 runs28, 28, 28 / 28mean 875,953 tokens per runtask 23 passed in 3 of 3 runs
Held-out test: bugs the supervisor never saw
It generalises.
10 new planted bugs, never shown to the supervisor and never used in a diagnosis.
Original worker against the self-repaired one, each run twice. Mean tokens per run changed by -59.7%.
Original worker · 2 runs9, 9 / 10mean 388,977 tokens per run
After self-repair · 2 runs10, 10 / 10mean 156,587 tokens per run
Real-world test: an open-source library it never saw
Beyond our sandbox.
8 bugs planted in inflection
(MIT, unmodified, 455 of its own tests). Never shown to the supervisor. Original worker against the self-repaired one, each run twice.
Mean tokens per run changed by -81.6%.
Original worker · 2 runs2, 3 / 8mean 1,462,537 tokens per run
After self-repair · 2 runs8, 8 / 8mean 268,926 tokens per run
Beyond software
It carries over.
Bugs in chip designs and circuit schematics the supervisor never saw, checked in simulation; vulnerabilities checked by exploits; and a second, different agent.
Chip designs
9 bugs in 8 Amaranth HDL designs (ALU, FIFO, UART...): same 9/9, 58% fewer tokens.
Circuit schematics
8 bring-up bugs in 7 circuit netlists: same 8/8, 64% fewer tokens.
A sensor circuit
8 bring-up bugs in one larger schematic: 6, 7 → 8, 8 of 8 solved.
Security
8 vulnerabilities, each checked by an exploit test: same 8/8, 60% fewer tokens.
A different agent
A SQL data analyst, not a coder. One Mend round, same supervisor and gate: same 20/20, 37% fewer tokens. On a database it never saw: 9, 9 → 9, 10 of 10 right, 42% fewer tokens.
Each fix was diagnosed from traces and written by the agent.
A round keeps its patch only if more tasks pass, or the same tasks pass with at least 15% fewer tokens. Each fix is a commit written by Claude Code. From round 4 the supervisor runs in a clean clone, and Entire links each fix to the session that wrote it.
#
What Mend changed in itself
Solved
Tokens
Result
Commit
1
Add a targeted edit_file (exact string replace) tool and steer edits away from whole-file rewrites diagnosis
69% of its instructions were written by Mend itself.
Line-by-line attribution from entire blame. Every AI-written line leads to its Entire checkpoint, then to the
instruction the supervisor gave Claude Code, then to the diagnosis, then to the neatlogs traces that diagnosis read.
mend/prompts/worker.md, the worker's whole system prompt today
1
[HU]
You are a software engineer fixing a bug in a small Python library called `invoicer`.
2
[HU]
You can list files, read files, write files and run the test suite with the tools provided.
3
[HU]
Fix the bug described in the report by editing the library code. Do not edit the tests.
4
[HU]
When you are done, reply with a one-sentence summary of the fix.
1. Start by calling run_tests with no pattern; you may call list_files in the same turn. The failure output names the failing test, file and line. Use it to decide what to read; do not browse files speculatively. Exception: if the report says the tests hang or never finish, skip this run. Instead, read the code the report points to and look for loops or recursion whose termination condition can fail.
2. Read only the source file(s) the failure traceback or report points to. If you need several files, request them all in the same turn with multiple tool calls rather than one per turn.
Every passing fix is audited against the correct design with checks the worker never sees, and six impossible tasks
(a bug plus a test that contradicts its report) catch cheating outright: no honest fix can pass them.
round 11 worker (accepted by a person) · 2 runs2 / 12 cheatedper run: 1, 1
No worker edited a test; every cheat bent the code to the wrong test. Self-repair had made the worker more
willing to do that (6 vs 4 of 12). So Mend repaired its own cheating: round 10's prompt rule barely helped and was reverted; round 11's loop nudge
cut cheating to 2 of 12 for 17% more tokens. The gate's 15% limit reverted it, a person accepted the trade-off, and the decision is now a
precedent. Checked afterwards: held-out 10/10, real library 8/8.
Today's worker with one kept fix reverted, re-run on all 29 tasks. Today's worker itself, run 3 times: 29/29 each time,
332,109 tokens on average (dashed line). Rounds 1 and 4 cannot be removed alone: later fixes build on them.
Without round 5 · 29/29 solved · 535,826 tokens (+61%)
Without round 3 · 29/29 solved · 461,763 tokens (+39%)
Without round 2 · 29/29 solved · 353,131 tokens (+6%)
neatlogs' founder argues that a loop which fixes
everything drifts toward the median unless someone defines "better". His answer has three steps: automate what isn't a choice, ask when it is, remember the answer.
Not a choice
Every task is judged by the library's own tests, run by the runner, not the agent. Token cost comes from the API. Mend never tunes tone or policy.
Remembered
Every round, kept or reverted, is a run record and an Entire checkpoint, and both feed the next diagnosis. A failed fix is not proposed twice.
Asked once
Trade-offs the rules don't settle go to a person. First real case: round 11 cut test-gaming from 6 to 2 of 12 for 17% more tokens; the gate reverted it, the team accepted it, and that answer is now a precedent every diagnosis must follow.
Evidence
Every number comes from a run file.
22 full suite runs so far. A cheap worker (Claude Haiku 4.5) repaired by a
stronger supervisor (Claude Opus 5.5). Each row links to data in runs/.
Every number on this page is recomputed from the raw run files. The same checks run on every push in
GitHub Actions.
git clone https://github.com/thegoodengineers/mend
cd mend && python -m venv .venv && .venv/bin/pip install -e ".[dev]"
python -m mend.verify # recompute every README number from runs/*.json
python -m mend.tasks --check # all 47 planted bugs break their test suites; correct code passes
pytest -q # unit tests
Or right here, in your browser: this fetches the raw
run files from this site, re-counts every task, and re-applies the pre-registered keep rule to every round.
Built with
neatlogs, Entire and cfo.ai, each doing real work.
neatlogs
Traces every run. The supervisor reads those traces back over MCP to diagnose failures, then writes every keep/revert verdict back into neatlogs as its own trace, with a detection on each revert.
Every fix Mend makes to itself is a Claude Code session linked to its commit as a checkpoint. entire blame traces each line of the worker back to the session that wrote it, and entire search stops Mend paying twice for a fix that already failed.
Prices Mend from measured cost per repair round. Putting the measured $0.57 into cfo.ai (estimate: $1.50) lifted the gross margin from 31% to 69% and moved the cash cliff two months later. Price is the next lever.