liveBook · Manning

Darwin Gödel Machine

As explained in Self-Improving Agents

DGM is an evolutionary search system that retains an archive of candidate code variants and uses it to generate and evaluate further variants.

A small population can find a good agent prompt and still get stuck. As its candidates converge, an unusual low-scoring branch may disappear before a later mutation can make it useful. The Darwin Gödel Machine (DGM) addresses that failure with evolutionary archive search: keep every tried candidate available for future sampling, rather than breeding only from recent survivors. section 4.3.1 section 4.4.3

DGM follows a vary–select–remember loop, but replaces a small, forgetful population with an archive that never truncates. It does not require a mathematical proof that a self-change will help: it runs the change and measures the result. The original system improved Python harness code; this prompt-focused version mutates agent context instead. section 4.0 section 4.3.1

One iteration makes the archive useful rather than merely large:

  • Sample a parent, usually from strong candidates but sometimes from anywhere in the archive. section 4.3.5
  • Reflect on the parent’s recorded trajectory, mutate its content, and measure the child. section 4.3.5
  • Append the child without deleting older candidates; record its score and parent link so the run remains traceable. section 4.3.5

Recovering an abandoned branch

On a revenue task, a main line of prompts climbs to a good score but stalls. A low-scoring, structurally different branch remains in DGM’s archive. Sampling it later leads to phrasing that excludes both cancelled and returned orders, passing the plateau that the converged population could not cross. The win depends on retaining and revisiting that earlier branch, not on changing model weights. section 4.3.5 section 4.3.1

Listing 4.8 Never discard, and sample by exploit-or-explore (06_revenue_dgm_loop.py)
def sample_parent(archive):                          #A
    ranked = sorted(archive, key=lambda e: e["score"],
                    reverse=True)
    if random.random() < EXPLOIT_P:   # usually exploit
        return random.choice(ranked[:3])   # a top candidate
    return random.choice(archive)     # else explore any member
 
for it in range(iters):
    parent = sample_parent(archive)                  #B
    diagnosis = await reflect(parent["content"], parent["traj"])
    child = await mutate(parent["content"], diagnosis)
    score, _, traj = await measure_full(child)
    child_art = parent["art"].mutate(new_content=child,  #C
                                     created_by="dgm")
    await store.record(                              #D
        Variant(artifact=child_art, parent=parent["art"],
                search_method="dgm"),
        GapMeasurement(score=score),
    )
    archive.append({"art": child_art, "content": child,
                    "score": score, "traj": traj})   #E

The listing shows the two decisive operations: occasionally sample from the whole archive, then keep the measured child and its lineage record. section 4.3.5

That memory is expensive: a growing archive and many iterations mean substantially more model calls than a small-population search. Use it when a reliable score justifies pursuing a hard final improvement across a deceptive low-scoring branch. On easier tasks or noisy signals, the extra search may not pay off. A highest-scoring candidate is not automatically the one deployed; promotion remains a deliberate gate. section 4.3.5 section 4.4.3

How Self-Improving Agents covers it

How deep it goes
Works through parent sampling, reflection, mutation, measurement, archive recording, and lineage; does not establish improvement by formal proof.
Examples
Traces a revenue-task prompt that revisits a low-scoring branch and learns to exclude cancelled and returned orders.
What it assumes
Assumes familiarity with an agent improvement loop while introducing evolutionary search from its simplest form.
What you can do after
Build it from scratch using an unpruned archive, exploit-or-explore parent sampling, measured mutations, and parent-linked records.
How it connects
Connects evolutionary search and the Gödel machine to GEPA, reflection, mutation, and lineage trees.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Self-Improving Agents. The section links point to the parts of the book it draws on.