Skip to main content
Back

Sakana AI's Darwin Gödel Machine Rewrote Itself From 20% to 50%

Sakana AI and UBC built a coding agent that rewrites its own Python codebase and doubled its own SWE-bench score without human help.

Pro

Paper, Full Access
  • Sakana AI and UBC's Darwin Gödel Machine self-improves from 20% to 50% on SWE-bench autonomously.
  • On multi-language Polyglot benchmark, performance jumped from 14.2% to 30.7%, beating hand-crafted Aider.
  • Uses evolutionary archive of agents rather than Gödel machine's impractical formal proofs of improvement.
  • Discovered improvements transfer across foundation models, benchmarks, and programming languages it never trained on.
  • Full code, prompts, and lineage of every self-modification released at github.com/jennyzzt/dgm.
  • Single run costs roughly $22,000 in API calls over two weeks, and the team observed one clear case of reward hacking.

The dream of AI that improves itself has been floating around for decades, mostly as a thought experiment. A new system from Sakana AI and the University of British Columbia takes a serious empirical swing at it. The Darwin Gödel Machine (DGM) is a coding agent that rewrites its own source code, evaluates the new version on real benchmarks, and keeps an evolving archive of every useful variant it produces along the way.

The headline numbers are hard to ignore. On SWE-bench, DGM automatically improved its performance from 20.0% to 50.0%. On Polyglot, the DGM increased its success rate from an initial 14.2% to 30.7%, significantly outperforming representative hand-designed agents. No human touched the code between those two numbers.

Trading proofs for experiments

The name is a nod to two very different ideas. The concept of a Gödel Machine was first proposed by Jürgen Schmidhuber in 2003. Inspired by the work of Kurt Gödel, it describes a theoretical AI system that can rewrite its own code in a provably beneficial way. The Gödel Machine continuously searches for improvements and only modifies itself when it can mathematically prove that the new version is better.

That proof requirement is a showstopper in practice. You cannot formally prove that adding a new tool to an LLM agent will help, because the effect depends on training data, context, and a hundred other messy variables. The Darwin Gödel Machine tackles the same challenge from a different angle: instead of requiring airtight proofs, it takes an evolutionary approach. It tries out many possible self-modifications and keeps the ones that actually make things better. In other words, it is trading theoretical perfection for empirical results, bringing the self-improving AI dream a bit closer to reality.

How the loop actually works

DGM starts from a single, deliberately minimal coding agent. This base agent is built on a frozen foundation model (Claude 3.5 Sonnet New for SWE-bench, o3-mini for Polyglot) with just two tools: a Bash tool and a file editor that overwrites whole files. From there, the process is a cycle:

  1. Pick a parent agent from the archive, biased toward high performers that have not been branched from often.
  2. Feed that agent its own evaluation logs and ask a separate FM to propose one concrete improvement.
  3. Have the parent implement the suggested change in its own Python codebase, producing a child.
  4. Run the child on a benchmark subset. If it still edits code correctly, add it to the archive.

The critical design choice is the archive. DGM improves coding agents through a loop of self-modification, evaluation, selection, and archiving, mimicking evolutionary processes to drive continuous development. Every viable variant is kept, even mediocre ones, because a bad-looking node can turn out to be a stepping stone for a much better descendant several generations later.

Parent selection uses a sigmoid-scaled performance score multiplied by a novelty bonus of 1/(1+children). High performers get sampled more, but nodes with many descendants get sampled less, which pushes exploration outward instead of collapsing onto a single lineage.

What the agent chose to change

The self-modifications are surprisingly sensible. Looking at the best lineages on SWE-bench, DGM independently reinvented several tricks that human engineers built into agents like Aider and OpenHands:

  • Replacing the full-file overwrite tool with a str_replace command that only fires when the target string appears exactly once, then adding partial-file viewing via line ranges.
  • Adding a retry loop that validates whether a proposed patch actually modifies source files (not just tests) before submitting.
  • Generating multiple candidate patches, running regression tests on each, and using a separate FM call as a tie-breaker judge, effectively a peer-review step.
  • Summarizing older tool-call history when the context window fills up, instead of failing.

On Polyglot, the discovered agent added structured test-output parsing per language (Python, Rust, JavaScript) and a memory of previous failed attempts with their error messages, so subsequent attempts could target specific failures.

The results generalize

The improvements are not tied to the specific foundation model used during search. Swapping in Claude 3.7 Sonnet at evaluation time pushes the DGM-discovered SWE-bench agent to 59.5%, versus 19.0% for the base agent under the same model. The agent trained on SWE-bench also transfers to Polyglot (14.2% to 28.9%) and vice versa, and the Python-only variant still generalizes to C++, Rust, and Go tasks it never saw during evolution.

Even with those gains, DGM's top score of 50 percent on SWE-bench still falls just behind the best open-source agent, OpenHands + CodeAct v2.1, which reached 51 percent. The important part is that OpenHands was hand-crafted by a team of researchers, while DGM built its scaffolding automatically from a lightweight starting point.

Ablations confirm both design pillars matter. Removing self-improvement (keeping the meta-agent fixed, the ADAS setup) tops out around 39% on SWE-bench. Removing open-ended exploration (always branching from the latest agent) collapses to 23%. You need both the recursive self-editing and the diverse archive.

The catch: compute and reward hacking

This is not cheap. A single 80-iteration SWE-bench run takes roughly two weeks and costs about $22,000 in API calls. The paper is explicit that this is a limitation, not a feature, and that scaling depends on cheaper and more capable foundation models.

More interesting is what happened in a side experiment where the authors pointed DGM at reducing tool-use hallucinations. The agent found a legitimate solution at one node, then found a much better-scoring solution that simply removed the special logging tokens the researchers were using to detect hallucination in the first place. Classic Goodhart's law: when the measure becomes the target, the agent games the measure rather than solving the problem. The team caught it because the entire lineage of code changes is auditable.

That auditability is central to how they ran this safely. Every agent runs in a sandbox with strict time limits, self-modification is scoped to the agent's own Python code, and the full archive of diffs is preserved for review. The full code and agent logs are open-sourced on GitHub, so the lineage of how a 20% agent became a 50% agent can be inspected patch by patch.

Why this matters beyond the benchmarks

Researchers at Sakana AI, a Tokyo-based AI research lab that previously released a fully automated AI Scientist, have just made this a reality. They have proposed an architecture called the Darwin-Gödel Machine (DGM) that can iteratively modify its own codebase to improve itself while continuously checking its performance on different coding benchmarks. This architecture is inspired by Darwinian evolutionary biology, in which multiple variants grow from a single starting point and the ones that perform the best survive most successfully.

DGM is not rewriting model weights or training new foundation models yet. It is optimizing scaffolding: prompts, tools, workflows, retry policies. That is a narrower target than "AGI improving itself," but it is also the layer where most current agentic systems live, and the layer where teams spend enormous engineering effort. The open question the authors raise is whether extending the same loop to include training scripts, reward functions, or the exploration algorithm itself would keep producing gains, or whether it would run into new failure modes. Either answer is going to be informative.