I Built an AI Agent That Rewrites Its Own Code (in ~150 lines)
A tiny Darwin Gödel Machine that edits itself and keeps only changes that verifiably score higher. TL;DR: I built a small program that improves itself . It looks at the tasks it's failing, edits its own code to fix them, and keeps a change only if the change actually makes it score better on a test. It goes from passing 1 of 8 tasks to 8 of 8 — and nobody wrote those fixes but the program itself. It runs on a laptop in under a second. No fancy hardware, no API key. The old dream: software that improves itself Normally, software only gets better when we make it better. You write code, you find a bug, you fix it, you ship again. The program never improves on its own. People have wanted "software that improves itself" for decades. The classic version (called a "Gödel Machine") had one rule that made it impossible to build: before the program could change a line of its own code, it had to mathematically prove the change would help. Proving that about real code is basically impossible, so the idea never worked. In 2025, researchers found a way around it with the Darwin Gödel Machine . They dropped the "prove it first" rule and replaced it with something every engineer already trusts: Try the change. Run the tests. If the score went up, keep it. If not, throw it away. That's it. It's basically how we all work — make an edit, run the test suite, keep what passes. The twist is that the program is the one making the edits. In the real paper, this let an AI coding assistant improve its own tooling and jump from solving 20% to 50% of a hard benchmark of real GitHub issues. I wanted to actually see this happen, so I built the tiniest version I could. The 10-second version Start After improving itself What it can do only uppercase learned 6 more skills on its own Test score 🔴 1 / 8 🟢 8 / 8 Who wrote the fixes? — the program did Start: ███░░░░░░░░░░░░░░░░░░░░░ 1/8 (only knows: uppercase) +reverse ██████░░░░░░░░░░░░ 2/8 +dedup_csv █████████░░░░░░░░░ 3/8 +sum_csv ████████████░░░░░░