Self-Evolving AI

An agent that never changes repeats its mistakes. An agent that keeps what worked gets better. On the lecture’s GPU speed task, four agents sharing notes cut the best known time from 1,363 cycles to 1,103.

Learn how agents manage their own memory, evolve programs and even train their own weights while they work, and what keeps such a loop from collapsing.

Picture a lock with 12 dials. You may try any setting, and the lock only says how close you are. Press Run 60 rounds and watch three searchers try. One guesses fresh each time. One keeps an archive of its best settings. Four share one archive. The best score climbs fastest for the team. Then we build, piece by piece, every part of that loop: the memory, the proposer, the judge and the team.

You need a rough idea of what an LLM agent is (a language model in a loop that calls tools) and a little Python for the code. We build the rest from zero.

Based on Lecture 14.1 of MIT Multimodal AI (Spring 2026), taught by Paul Liang and the MIT Multisensory Intelligence group. Lecture slides. Every idea is re-taught here in our own words and devices.

Search for a better solution

30

Illustrative toy, not a result from the lecture: the task is to guess a hidden row of 12 digits, scored by how close the row is (1.00 is perfect). Each curve is the mean of 24 seeded runs, computed live in your browser. One round is one unit of wall-clock time: asking fresh and one agent make 1 trial per round, four agents make 4.

Chapter 0

Why a Frozen Agent Hits a Ceiling

See why an agent that never changes keeps paying for the same mistakes, and what it means for an agent to improve itself

Picture an agent that fixes broken spreadsheets for a finance team. On Monday it opens a file, misreads a date column, and gives the wrong totals. A person corrects it. On Tuesday a new file arrives with the same date column. The agent misreads it again.

Nothing is wrong with the agent’s skill. It simply has no way to keep what it learned. Each run starts from the same blank page, with the same weights, the same prompt and the same habits. A person who made the same error twice in a row would feel foolish. The agent does not feel anything, so it pays the cost forever.

This lecture is about agents that stop doing that. We call them self-evolving agents: systems that change themselves as they work, using feedback they gather on their own, so that the next attempt is better than the last. The word “self” matters. A human who edits the prompt each week is improving the agent. A self-evolving agent does that editing itself.

Where this lesson sits in the week

This is the last week of the course, and Lecture 14.1 is a tour of advanced topics. It lists six: a recap of the course, native multimodal models and mixture of experts, advanced fusion, self-evolving multimodal agents, extending human senses with touch, smell and taste, and human-AI interaction and safety. This lesson teaches the fourth. The logistics are short. Course evaluations are open. Homework 5 is due Friday, May 8. Project presentations are Tuesday, May 12, and the final report is due Tuesday, May 19.

The problem the lecture starts from

The lecture opens this part with multimodal reasoning agents: agents that solve hard problems by thinking step by step and taking actions across several kinds of input, such as video, speech and text. Its example is a scene from a sitcom. A character says, “It’s just a privilege to watch your mind at work.” The agent builds a joint picture of the faces, the voice and the words, and decides: this person is being sarcastic, and they seem to be close friends. It can then quote earlier episodes, or even write a story set in a different culture.

Every one of those steps adds text to the agent’s working notes. The slide states the cost in one line: reasoning context is getting longer and longer. Chapter 1 shows what to do about it. First we look at the bigger issue.

Frozen versus evolving

A frozen agent has fixed weights, a fixed prompt and no memory across runs. Its quality on a task is a coin it flips again every time. An evolving agent turns each failure into something it keeps: a note, a rule, a better program, even a small change to its own weights. Its quality is a number that can only go up, if it keeps the right things.

Try it. The task below hides four pitfalls. On each attempt, each pitfall has a 40% chance of tripping the agent, unless the agent has already written a note about it. One trip fails the attempt. Switch notes on and off and compare ten attempts.

Run the same task ten times

Each circle is one attempt: green if it worked, red if it failed. The bars below show how many of the four pitfalls the agent has a note for. Press Roll new runs to see another seed.

Illustrative toy, not from the lecture: 4 hidden pitfalls, each with a 40% chance of tripping an attempt when the agent has no note for it. The averages are over 400 fresh runs, computed in your browser.

With notes off, the agent succeeds about 1 attempt in 8, and ten more attempts will not change that. With notes on, early attempts fail while the notes pile up. Each note removes one pitfall for good, so successes grow more common. The cost of learning each lesson is paid once.

Four things that can change

An agent has four places where an improvement can live, and the rest of this lesson visits each one. The context is what the agent reads right now: its memory, its notes, its working text. The harness is the code around the model: prompts, tool definitions and the control loop. The model is the weights themselves. The environment is the task set and the reward. The lecture’s closing slide describes the goal: agents that constantly verify what they know and improve over time, beyond static human supervision. It points to a blog post that organises the whole field; we weave it into Chapters 2 and 7.

The idea in one line. A self-evolving agent is a loop: try, judge the result, keep what helped, try again. The judge must be something outside the agent’s own opinion, or the loop learns nothing true.

The road

  1. An agent that edits its own memory: MEM1 keeps a constant-size state instead of the whole history.
  2. Three ways to evolve: fixed search, one free agent, a team, on four steps.
  3. AlphaEvolve and OpenEvolve: a language model as the mutation step of evolution.
  4. Evolution as tree search: why a few good samples are enough.
  5. Evolving the model: training the weights at test time.
  6. CORAL: agents that specialise, share memory and get a heartbeat.
  7. The compounding loop: retention, entropy and grounding.
  8. Build the loop: a working evolver in about forty lines.
  9. Field guide: numbers, checklist, code and where to go next.

A worked example: what ignorance costs

Take the toy above and do the arithmetic by hand. Each pitfall trips the agent with probability 0.4, so it stays clear of one pitfall with probability 0.6. The four pitfalls are independent, so the chance of clearing all four in one attempt is 0.6 × 0.6 × 0.6 × 0.6 = 0.1296.

A success rate of 0.1296 means about one attempt in 7.7. For a frozen agent that figure never moves. In ten attempts it expects 1.3 successes, which matches the average the device printed. Now give the agent notes. After the first failure it knows one pitfall, so it must clear only three: 0.6 × 0.6 × 0.6 = 0.216. After two notes the odds are 0.36. After three they are 0.6. After four they are 1.0.

So each note raises the success rate by a clear factor: 1.67 times at each step (0.1296 to 0.216 to 0.36 to 0.6 to 1.0). Notes do not need to be clever. They only need to be kept and read. That is the whole case for self-evolution in one number, and it is why the first question to ask about any agent is: where does it store what it learns?

Where the lecture goes from here

The lecture does not build one big system. It walks a ladder of autonomy. First it shows an agent that manages one thing, its memory. Then it asks how agents can choose their own functions, and how they can delegate to other agents. Next come systems that search for scientific discoveries by evolving programs. After that, systems that train the model itself while they search. Last, a team of agents with a shared memory. Each rung hands one more decision from a fixed rule to the agent. Keep that ladder in mind as we climb it.

An agent fails the same task on Monday and on Tuesday for the same reason. Which change makes it a self-evolving agent?

Chapter 1

An Agent That Edits Its Own Memory

Follow MEM1 as it replaces a growing pile of history with one small state that it rewrites every turn

You are asked to plan a trip, and the question has sixteen parts: a flight, a hotel near the venue, a restaurant open late, a train back, and twelve more. You will make about forty lookups. How do you keep track?

You could keep every page you ever opened, stacked on the desk. By lookup forty the desk is buried, and you spend more time searching the pile than planning. Or you could keep one index card. After each lookup you rewrite the card: what is settled, what is still open, and the one fact you must not lose. The pile is a log. The card is a memory.

Most language agents work like the pile. At every turn they append the new observation to the prompt and send the whole thing back to the model. The lecture’s slide on multimodal reasoning makes the same point: the reasoning context grows longer and longer. A token is the small piece of text a model reads (a short word or part of one). Prompt length is counted in tokens, and it grows with every turn.

Why the pile hurts

Three costs follow. The first is money and time: the model re-reads the whole prompt each turn, and attention work grows faster than the prompt (see the CS 329Z lesson on agent memory for the full story). The second is a hard limit: the prompt must fit in the model’s context window, the most text it can read at once. The third is quality. The paper the lecture cites says long inputs hurt reasoning, most of all on inputs longer than any the model saw in training. The facts are in the pile, but the model has to dig for them.

MEM1: keep one card

The lecture’s example is MEM1 (Zhou et al., ICLR 2026, code at github.com/MIT-MI/MEM1). The slide gives its title: Learning to Synergize Memory and Reasoning for Efficient Long-Horizon Agents. A long-horizon task is one that needs many turns before it is done.

MEM1 keeps a single compact internal state. At each turn the model reads three things: the task, its previous internal state, and the newest observation from a tool. It then writes a new internal state that merges the old one with what it just learned, and it drops anything redundant. The old state and the old observation are discarded. The prompt never grows.

The clever part is that one piece of text does two jobs. It is the memory, and it is also where the model reasons. The agent thinks by rewriting the card. So “what to remember” is not a separate module. It is part of thinking.

The data flow

Here is one turn, written as the model sees it. The format is illustrative; MEM1 uses its own tags.

one MEM1 turn (illustrative format)# input to the model, about 300 + 350 + 600 tokens
task:       "Plan the 16-part trip ..."               # fixed, about 300 tokens
state_t-1:  "Flight booked Tue 9am. Hotel: need within 2 km. Open: train home, late dinner."
observation:"Hotel Lark, 1.4 km, 118 USD, free cancel ..."   # newest tool result
# output of the model
state_t:    "Flight Tue 9am. Hotel Lark 1.4 km 118 USD (ok). Open: train home, late dinner."
action:     search("late dinner near Hotel Lark")

The prompt at turn 30 has the same size as the prompt at turn 3. That is what constant memory means.

See the two designs side by side. Drag the turn count. The numbers are a toy: each observation is 600 tokens, each reasoning step is 150 tokens, the task is 300 tokens, and the internal state stays near 350 tokens.

Pile versus card

The purple line is an agent that appends every turn. The warm line rewrites one state. The box shows what the model reads at the turn you pick.

16

Illustrative token counts, not the paper’s. The paper reports that MEM1-7B improves performance 3.5 times and cuts memory use 3.7 times against Qwen2.5-14B-Instruct on a 16-objective multi-hop question task (arXiv 2506.15841).

At turn 16, the appended prompt holds about 12,300 tokens. The rewritten one holds about 1,250. The gap keeps widening with every turn. The paper measures its own saving more carefully, and it finds the same direction.

How does it learn what to keep?

Nobody tells MEM1 which facts matter. It learns this with reinforcement learning: the model tries whole tasks, gets a reward only when the final answer is right, and nudges its weights toward behaviour that earned reward. If dropping a fact leads to a wrong answer, that way of writing the state earns no reward. If keeping a fact helps, it does. Over many tasks the model learns a policy for its own memory. The weights change in training; the memory changes within every task.

The authors also build harder training tasks by chaining existing question sets into longer sequences, so the agent practises many-step goals. The paper reports that the trained agent keeps working beyond the length it was trained on.

Failure mode: the card that forgets

The symptom: late in a long task, the agent asks a tool for something it already knew. The measurement: count repeated lookups per task, and check whether the answer sat in an earlier state. The fix: reward final correctness, so a state that drops a needed fact is punished, and test on tasks longer than the training tasks. Chapter 7 names this pattern catastrophic forgetting, one of three ways a loop fails.

A worked example: how much work the pile costs

Attention is the model’s way of comparing each word with every word before it. If a prompt has n tokens, one layer makes about n × (n + 1) / 2 comparisons. Use it on the two prompts at turn 16 of the device.

The appended prompt has 300 + 16 × 750 = 12,300 tokens. Its comparisons: 12,300 × 12,301 / 2 = 75,651,150, about 76 million per layer. The rewritten prompt has 300 + 350 + 600 = 1,250 tokens. Its comparisons: 1,250 × 1,251 / 2 = 781,875, about 0.8 million.

The ratio of the prompts is 12,300 / 1,250 = 9.8. The ratio of the work is 75,651,150 / 781,875 = 96.8, nearly the square. A prompt that is ten times shorter is about a hundred times cheaper to read. This is why a small constant state is worth far more than its size suggests. It also shows why MEM1 matters most in the long tasks, where the pile would blow up.

What the model must learn to write

A good state is not a copy of the observation. Look at the example turn again. The old state said “Hotel: need within 2 km”. The observation gave a hotel at 1.4 km for 118 USD. The new state keeps the decision (“Hotel Lark 1.4 km 118 USD (ok)”) and drops the sales text. It also keeps the list of what is still open. A bad state would either keep every detail and grow, or drop the open list and lose its place.

That is a real skill, and it is learned from the reward at the very end of the task. The agent that writes better states gets more answers right, and the training pushes the weights toward it. No human ever says what a good state looks like.

What lets MEM1’s prompt stay the same size from turn 3 to turn 30?

Chapter 2

Three Ways to Evolve

Compare a fixed search, a free single agent and a team of agents on the same four steps, and see who makes each decision

A kitchen needs a better soup recipe. In the first kitchen, the owner writes a rule: every night, taste three versions, keep the best, tweak it a little. Nobody thinks about the rule. In the second kitchen, one cook decides for herself what to taste, when to taste it and what to write in the recipe book. In the third kitchen, a team of cooks works in parallel and writes into one shared book that everybody reads.

All three kitchens improve the soup. They differ in who is in charge of the improving. That is the whole idea of this chapter, and it is the lecture’s slide on self-evolving agents.

The two questions

The slide begins with MEM1, the agent from Chapter 1 that learns to manage its own memory. It then says that other agents manage tools, APIs, search and coding, and it poses two questions. How can agents automatically decide which functions to use for a given task? The answer it gives is self-evolving agents. How can agents automatically delegate tasks to other agents and organise themselves? The answer is self-evolving multi-agent systems. The slide credits a figure to the CORAL paper (Qu et al., 2026), which we meet in Chapter 6.

The four steps every evolving loop has

The figure compares three designs on the same four steps. Learn the four steps first, because every system in this lesson is a variation on them.

  1. Retrieve. Pick what to read: old solutions, notes, papers, error logs.
  2. Propose. Write a candidate: a new program, a new plan, a new note.
  3. Evaluate. Run the candidate against a judge and get a score or a verdict.
  4. Update. Store what was learned, so the next round starts from it.

In a fixed evolutionary search, rules own all four steps. Context is chosen by fixed rules. The model proposes from the context it is handed. Evaluation fires on a fixed schedule, and a fixed rule updates the store. The model is a clever part inside a machine that someone else built. This is the family AlphaEvolve belongs to (Chapter 3).

In an autonomous single-agent design, the agent owns the loop. It chooses what to inspect, plans and tests its own changes, decides when a run is worth evaluating and decides what to write down. In an autonomous multi-agent design, several agents do this at once. They read from a shared memory, propose in parallel, schedule their own evaluations and write what they find back to the shared memory.

Pick a design below and read down the four steps. The words come from the slide’s figure.

Who decides each step

Choose a design. Each row is one step of the loop. The coloured tag says who makes the decision: a fixed rule, one agent, or the team together.

Cell wording follows the figure on the lecture slide (from the CORAL paper). The count of steps owned by an agent is simply read from the rows.

Notice what changes between the first design and the second. Nothing about the four steps. What changes is whether a fixed script or a language model sits behind each one. Autonomy is the share of the loop that the agent controls.

What the blog adds: four things that can evolve

The lecture ends with a blog post that surveys 66 works from 2022 to 2026 (Qu, The Compounding Loop, quao627.github.io/blog/self-evolving-agents). It gives the field a clean vocabulary, and we use it from here on. It asks what the loop changes. There are four targets. The model is the weights. The harness is the code around the model: prompts, tool schemas and orchestration. The context is memory, skills and search state that change during a run. The environment is the task set and the rewards. The post notes that the reward function belongs to the environment, not to the agent.

It also asks when the change happens. Harness changes usually happen offline, before deployment. Context changes happen at run time. The post calls confusing these a common mistake. For example, tools that tune a prompt offline are improving the harness, not the context. MEM1 from Chapter 1 evolves context, at run time, every turn. AlphaEvolve evolves a population of programs while its model stays frozen. TTT-Discover (Chapter 5) changes the model itself.

Two questions to ask of any system. What does the loop change: model, harness, context or environment? And who owns each of the four steps: a rule, an agent, or a team? These two questions place any paper in the lesson on one page.

You may know these ideas by other names. Our lessons on context evolution and harness evolution teach two of the four targets in depth, and agent memory covers the storage side of Retrieve and Update.

A worked example: place three systems on the grid

Use the two questions on three systems from this lesson and write the answers down.

  1. MEM1. What changes? The context, at run time, each turn. Who owns the steps? One agent. It reads the old state, proposes a new state, and the training reward is the evaluation. It sits in the “single agent” column, with weights trained once beforehand.
  2. AlphaEvolve. What changes? A population of programs, with the model frozen. Who owns the steps? Rules: a sampler picks parents, a fixed scheduler runs evaluations, a database rule stores results. It sits in the “fixed search” column.
  3. CORAL. What changes? Programs, plus notes and skills in a shared memory. Who owns the steps? Several agents, each deciding for itself, with a heartbeat from the system. It sits in the “team” column.

Two systems can use the same model and sit in different columns. That is the point of the grid. The model is a part. The wiring decides the column.

Why the column matters

Each step to the right buys flexibility and costs control. A fixed search is easy to predict: you know exactly when it will evaluate and what it will store. A free agent can find moves nobody planned, such as running a quick test before a long one, but its path is harder to audit. A team can cover more ground, but it needs a shared memory that stays consistent when several agents write at once. Chapter 6 shows how CORAL pays for that freedom with isolation and a separate judge.

A system updates its store of past solutions with a fixed rule, picks the model’s context with a fixed rule and runs the evaluator on a fixed schedule. Which design is it?

Chapter 3

A Language Model as the Mutation Step

Step through one generation of AlphaEvolve and OpenEvolve, and see why a judge that runs the code makes wild guesses safe

Suppose you want a faster way to schedule jobs on a huge cluster. Nobody knows the best rule. You could write a rule, test it, tweak it, test again, and repeat for a month. Each test needs a realistic simulation. You would try maybe fifty ideas in that time.

A machine can try fifty thousand. The trouble is that a machine needs someone to suggest the next idea, and suggesting a good change to a program is the part that took you a month of thinking.

The lecture’s slide on this topic says it plainly: agents now help with scientific discovery. It shows two headlines. One is the Nature article on discoveries from program search with large language models. The other is the May 2025 announcement of AlphaEvolve, a Gemini-powered coding agent for designing advanced algorithms. The next slide shows its overview figure next to OpenEvolve, an open-source system built on the same idea that you can run yourself.

Evolution, with an LLM as the mutation

Biological evolution has three parts. Variation makes copies with small changes. Selection keeps the copies that work. Inheritance lets the next round start from the winners. Software has copied this for decades under the name genetic algorithms. Their weak spot is variation. A random mutation to a program, such as flipping a character, nearly always breaks it.

AlphaEvolve replaces the random flip with a language model. Given a program and its score, the model proposes a meaningful edit: swap an optimiser, restructure a loop, add a term. Most of its edits still do not help, but nearly all of them run. The model is the mutation operator: the step that makes a changed copy.

What the human writes, and what the system figures out

The overview figure splits the work cleanly. The human defines the what: the problem, the evaluation criteria (a function that scores any program), a starting program, and background knowledge. The system figures out the how with four parts. A prompt sampler builds the request to the model from earlier programs and their scores. An ensemble of LLMs proposes the edits. A pool of evaluators runs each new program and scores it. A program database stores every program with its scores, and it feeds the sampler the next round.

One generation is six steps. Press Next step below to walk through three of them on a task small enough to check by hand. The target is a table of five values, and the judge scores a program by how close its output comes.

One generation, step by step

The six boxes are the loop. The lit box is the current step, and the panel shows exactly what moves through it. Press Next step eighteen times, or use Play.

Toy task, not from the paper: make score(x) match the table (0 to 1, 1 to 2, 2 to 5, 3 to 10, 4 to 17). The score is 1 divided by 1 plus the mean squared error. The three proposals are scripted, the evaluator really runs each expression in your browser, and the second proposal is built to fail so you can watch the judge kill it.

Look at generation 2. The model proposed a change that referred to a name the program never defined. A plain chat model would say it with confidence. Here the evaluator ran the code, got an error, scored it 0 and moved on. The bad idea cost one evaluation and nothing else. This is the design’s key trade: the model may be wrong as often as it likes, because the judge is never fooled. We call this grounding: every suggestion meets a real measurement before it can matter.

The format of an edit

The model does not rewrite the whole program. It returns a diff: a block that says which lines to find and what to put in their place. The prompt asks for a SEARCH block and a REPLACE block. That keeps the output short, keeps the untouched code exactly as it was, and lets a plain script apply the edit. In the device above, the apply step is a string replacement.

What it found

The AlphaEvolve abstract reports results at Google and in mathematics. It found a more efficient scheduling heuristic for Google’s data centres, a simpler circuit design for a hardware accelerator, and a way to speed up training of the model behind it. In mathematics it found a method for multiplying two 4 by 4 complex matrices with 48 scalar multiplications, the first improvement over Strassen’s method in that setting in 56 years. The slide groups its solved problems into analysis, geometry and combinatorics. The system uses an ensemble of Gemini models, a fast one for many cheap guesses and a stronger one for occasional deeper ones.

For the full walk through the paper, see our AlphaEvolve paper lesson. For a design with a free-roaming agent in place of this fixed loop, go on to Chapter 6.

A worked example: the judge’s arithmetic

Check the toy’s scores by hand. The table says the answers are 1, 2, 5, 10, 17 for x = 0 to 4. The starting program returns x, so its outputs are 0, 1, 2, 3, 4. The errors (output minus target) are −1, −1, −3, −7, −13. Square them: 1, 1, 9, 49, 169. Their sum is 229, and the mean is 229 / 5 = 45.8. The score is 1 / (1 + 45.8) = 0.0214, which the device shows as 0.02.

Now x × x gives 0, 1, 4, 9, 16. Every error is exactly −1, so every square is 1 and the mean is 1. The score is 1 / (1 + 1) = 0.5. Finally x × x + 1 gives 1, 2, 5, 10, 17. Every error is 0, so the score is 1 / (1 + 0) = 1.00. The score rises with every good edit, which is what makes it a usable signal.

Realisation: what is in a real run

A real system adds three things to the toy. First, the prompt carries more than the parent: it also holds earlier programs that scored well on different measures, so the model can blend two lineages. Second, expensive judges use a cascade: run cheap tests first, and spend the costly simulation only on programs that pass. Third, the database is not a flat list. Our paper lesson describes it as inspired by an algorithm called MAP-Elites, which keeps the best program in each cell of a map of behaviours, plus an island model that keeps separate populations apart.

OpenEvolve, the open-source relative on the slide, follows the same plan. You supply the problem, an evaluation function and a starting program, then you plug in a model. The loop, the database and the diff format come with it.

The model in an AlphaEvolve-style loop proposes a change that crashes the program. What happens?

Chapter 4

Evolution Is a Tree Search

Watch a tree of programs grow, see why most branches die, and learn why the few that live are enough

You are climbing a foggy hill with a flashlight. You can see about three steps ahead. You also carry a notebook of every spot you stood on, with its height. At each pause you choose a spot from the notebook, take a few steps from it, and write down the new height. Most steps go downhill. Now and then one goes up, and from there you start again.

That is the lecture’s picture of an evolving coding agent. The slide calls it evolving solutions via tree search. Each program is a node. When the model edits a parent into a child, the loop draws a line between them. The result is a program evolution tree: a map of which program came from which.

The slide’s example: packing circles

The slide shows a figure from ShinkaEvolve, another open evolutionary agent. The task is circle packing: fit 26 circles in a square so that the sum of their radii is as large as possible. It is a hard shape puzzle with an exact score, which makes it a good test bed. The caption says that ShinkaEvolve beat AlphaEvolve’s solution with fewer than 150 program evaluations. It adds that the tree shows stepping stones: programs that did not look special alone, but that later programs built on.

The next slide shows the same effect as a scatter. Each dot is one program, plotted against the iteration that produced it. The dots form a cloud. A step line, the best score so far, rises in a few jumps. The title says it: few samples lead to improvements.

Why most samples do not help

Think about what a single edit does to a program that already works well. Most edits make it a little worse. Some change nothing. Only a few make it better. If the parent is nearly optimal, the odds fall further. So a healthy run shows a lot of dots below the best line, and only a thin trickle of improvements.

That is not waste. The cloud of failed programs is where the stepping stones hide. A program that scored below the best may still contain a good idea that a later edit will combine with another. Selection keeps the best, but the database keeps everyone.

Choosing a parent

The loop has one important decision: which parent do I edit next? The rule has two pulls. Exploitation says: pick the best program, since its children are most likely to be good. Exploration says: also pick others, since the best program might be at a dead end. Too much exploitation and the run gets stuck at a local peak. Too much exploration and it wanders. The toy below uses a simple rule, and the code is short enough to read in full.

pythondef pick_parent(archive, rng):
    top = sorted(archive, key=lambda p: -p.score)[:5]
    if rng.random() < 0.7:
        return top[0]            # exploit: the best so far
    return rng.choice(top)      # explore: one of the top five

Now the device. The task is the hidden-digit game from the top of the page. A node is one trial. Its height is its score. A line joins every child to its parent. Drag the slider to grow the tree.

Grow the tree

Each dot is one trial placed by when it ran (left to right) and its score (up). Grey lines join a child to its parent. The bright path is the chain of stepping stones that led to the best trial. Switch it off to see the whole cloud.

60

Illustrative toy, not the paper’s run: one evolving agent on the hidden-digit task, seeded. The first three trials are random guesses, then the parent rule above applies. A trial counts as an improvement if it scores higher than the parent it came from.

Drag to 60 trials. In the default run, only about a quarter of the children beat their parent. But the best trial’s ancestors form a path of steady gains, and the path starts from a modest first guess. That ratio, many tries for few wins, is why the number of evaluations matters so much. In the paper behind the slide, the saving came from needing fewer than 150 evaluations, not from a smarter single guess.

Failure mode: stuck at a peak

The symptom is a step line that goes flat for a long time while the cloud of dots keeps growing. The measurement is the share of children that beat their parent: if it drops toward zero, the run is exploiting a peak. The fix is more exploration. Pick parents that are not the best. Keep several separate populations, called islands, that rarely mix. Reward programs that are different, not only high. Chapter 6 shows a team doing this on purpose.

A worked example: the odds of a run with no wins

Suppose a quarter of edits beat their parent, as in the toy. How likely is a run of 20 edits in a row with no win at all? Each edit misses with probability 0.75, so the chance is 0.75 raised to the 20th power, about 0.003. A flat stretch of 20 is rare when the loop is healthy.

Now suppose the wins thin to one edit in twenty, because the program is near a peak. A flat stretch of 20 has probability 0.95 to the 20th, about 0.36. Over a long run, such flat stretches become normal. So the share of wins is a gauge. When it falls, the run is climbing something steep, and you should expect long waits between gains. If it falls to zero for a long time, you are probably on a peak that this parent rule cannot leave.

Why a tree and not a list

A list remembers only what scored best. A tree also remembers how each program was reached. That lets you answer questions a list cannot. Which parent produced the most winning children? Which chain of edits led to the best program? Did the winner descend from a weak program, a stepping stone? In the slide’s circle packing figure, the winning solution sits at the end of a path through several modest programs. Without the tree you would see only the final answer and miss the route.

The tree also gives the model a way to learn from history. If the prompt can show a parent together with its ancestors’ edits, the model can see which kinds of change paid off earlier in this very run. That is a form of memory, and it is why the archive is the loop’s most valuable asset.

In an evolution tree, 100 child programs are tested and 12 beat their parents. What does that say?

Chapter 5

Evolving the Model Itself

See what changes when an agent trains its own weights on one problem, using each improvement as the reward

A pianist has one week to master one piece. She could play it a hundred times with her current hands and hope for a lucky take. Or she could practise: every time a bar goes well, she notices and repeats it, and her hands change. By Friday she is a different pianist, built for that piece.

In Chapter 3 the model was a frozen mutation operator. It never learned from the loop. Every proposal came from the same hands. The lecture now asks: what if the model also learns while it searches? The slide puts it in one line. Recent works such as TTT-Discover and ThetaEvolve train the model at test time with the improvement score as the reward signal.

Three terms, from zero

Test time is when you use a model, as opposed to training time, when you build it. Normally weights freeze at the end of training. Test-time training keeps changing them on the problem in front of you.

Reinforcement learning (RL) is learning from outcomes. A policy is the model’s habit for choosing what to write next. The model tries something, gets a number called a reward, and shifts its habit toward what earned more. Our lesson on GRPO and DAPO shows how this is done for language models at scale.

Here the reward is the improvement score: how much better the new program is than what the loop had before. A change that raises the best score earns reward. A change that makes it worse earns none. The judge from Chapter 3 supplies the number, so no human labels anything.

The update, in one line

To see the mechanism, shrink the model to a menu of six kinds of edit, such as “change one constant” or “rewrite a loop”. The policy is a list of six probabilities. It picks one kind per attempt. When the edit improves the program, the update makes that kind more likely next time.

θ
The model’s weights. In the toy, six numbers, one per kind of edit.
η
The learning rate: how big a step to take. Too small and nothing changes. Too big and the policy locks onto the first lucky edit.
r
The reward: 1 if the attempt improved the best score, 0 if not.
b
A baseline: the average reward so far. Subtracting it means an edit is praised only for beating what is typical.
∇ log πθ(a)
The direction that makes the chosen edit a more likely choice.

edit kind “rewrite a loop” wins: r = 1, b = 0.11, so (r − b) = +0.89, and its probability rises.

Try it. Six kinds of edit hide different success rates, from 4% to 30%. The frozen policy picks all six equally. The learning policy shifts toward whatever pays.

Train while you search

The top chart counts improvements found so far, averaged over 40 seeded runs. The bars show one run’s policy at the attempt you choose. Switch updating on and off, and change the learning rate.

120
0.30

Illustrative toy, not from either paper: six edit kinds with success rates 4%, 8%, 30%, 5%, 12% and 6% (mean 10.8%). The update is the one in the equation above, applied to a softmax over six numbers. Real systems update billions of weights, but the idea is the same.

What the two papers do

TTT-Discover (Yuksekgonul et al., arXiv 2601.16175) changes the goal. Normal RL wants a policy that does well on average. Here the aim is one excellent solution to one problem, so the objective and the search favour the most promising attempts. It runs on an open model, gpt-oss-120b, and the authors report training runs costing a few hundred dollars per problem. Their areas include mathematics, GPU kernels, algorithm contests and a biology task, and in a GPU kernel competition they report a result up to 2 times faster than earlier art.

ThetaEvolve, drawn on the next slide, wires the same idea into the AlphaEvolve loop. One language model writes the programs. A prompt builder fills the prompt from a program database. A verifier scores each program. An optional RL step then updates the model. The loop and the learning feed each other: the database gives the model better prompts, and the model gives the database better programs.

Failure mode: the policy locks in

The symptom: after a lucky early win, the policy puts almost all its probability on one edit kind, and the improvement count stalls. The measurement: watch the spread of the six bars. In the device above, a learning rate near 1 collapses the policy within a few wins. In the run shown it locks onto the right edit and wins big, but a lucky early hit on a poor edit would lock in the wrong one. The fix: a smaller step, or a bonus for variety. A second risk is the judge itself: a model that trains on a reward will find holes in the judge if there are any. Chapter 7 returns to this.

A worked example: one update, by hand

Start with six edit kinds, all with probability 1/6 = 0.167, so all six scores (the raw numbers that the softmax function turns into probabilities: raise e to each score, then divide by the total) are 0. The agent picks “loop” and the edit improves the program, so the reward is 1. The baseline is 0.11, so the advantage is 1 − 0.11 = 0.89. Use a learning rate of 0.3.

  1. Chosen edit. Its score moves by 0.3 × 0.89 × (1 − 0.167) = +0.222.
  2. Each other edit. Its score moves by 0.3 × 0.89 × (0 − 0.167) = −0.045.
  3. Turn scores into probabilities. e0.222 = 1.249 and five copies of e−0.045 = 0.956 each, total 4.78. The sum is 6.03.
  4. New probability of “loop”. 1.249 / 6.03 = 0.207.

One success moved “loop” from 16.7% to 20.7%. Four more such wins push it past 40%. A miss does the opposite in a small way: a reward of 0 gives a negative advantage of −0.11, so the chosen kind loses a little. Over many tries the kinds that win often rise, and the kinds that win rarely fade.

Why not just copy the winner?

You might ask why we go to this trouble. Why not note that “loop” worked and always pick it? Because after the first few wins the best kind of edit changes. An edit that helps a rough program may do nothing for a polished one. A frozen rule written from early wins goes stale. The weights, by contrast, keep adjusting to whatever pays now, in this problem, with the program as it is today. That moving target is the reason the lecture talks about evolving the model and not only the prompt.

In test-time training for discovery, what is the reward signal?

Chapter 6

CORAL: A Team That Shares Memory

Learn how four agents, a shared notebook and a heartbeat beat a fixed evolutionary loop on a hard kernel task

A research lab has four engineers and one hard problem. In the first lab each engineer works alone, behind a closed door. If two of them walk into the same dead end, nobody knows. In the second lab there is a whiteboard in the hall. Everyone writes what they tried and what failed. And a manager walks by every hour and asks one question: “You have not moved in a while. What are you going to try instead?”

The second lab finds the answer sooner. That whiteboard and that manager are the heart of CORAL, the system on the lecture’s last two evolution slides (Qu et al., Towards Autonomous Multi-Agent Evolution for Open-Ended Discovery, arXiv 2604.01658; code at github.com/Human-Agent-Society/CORAL). Our CORAL paper lesson goes through the paper in detail. Here we learn the four ideas.

The four key ideas on the slide

Multi-agent specialisation. Several agents work on the same problem, and each follows its own line of attack. One may tune low-level details while another rewrites the structure. The mix covers more ground than one agent could.

Increased autonomy. Fixed loops, like the one in Chapter 3, decide for the agent what to read and when to evaluate. CORAL gives those decisions back to long-running agents. They explore, reflect and collaborate as they see fit. The paper’s complaint about earlier methods is that fixed heuristics and hard-coded exploration rules limit what an agent can do.

Shared memory. The agents keep one persistent store that all of them can read and write: notes, skills and results. A lesson learned by one agent is available to all, even after a long gap. This is the whiteboard in the hall.

Heartbeat mechanism. A heartbeat is a regular, automatic check-in. At set moments the system interrupts an agent and nudges it: reflect on what you did, consolidate what you learned, or change direction if you are stuck. Left alone, a long-running agent can circle one idea for hours. The heartbeat breaks that circle.

The guard rails

Freedom without limits is dangerous, so the paper adds safeguards. Each agent works in an isolated workspace so it cannot trample another’s files. The evaluator is kept separate, so an agent cannot rewrite the judge to give itself a better score. The system also manages compute resources, and watches each agent’s session and health. Agents run asynchronously: nobody waits for the slowest.

Feel the two mechanisms

Below is a toy landscape. The height at each spot is the score of a solution. There are eight modest hills and one tall, narrow peak. Four agents start at random places and climb by small steps. An agent that has not improved for five rounds is stalled. With the heartbeat on, a stalled agent is told to jump somewhere new. With shared memory on, the agents also keep a list of places already explored, and jump to somewhere not on the list.

Four agents, two switches

The top strip is the landscape. Each agent is a coloured dot with its trail, and the marks are places the shared notes call explored. The lower chart is the team’s best score so far, averaged over 60 runs, against the same team with both switches off.

40

Illustrative toy, not the paper’s experiment. Eight hills (heights 0.5 to 0.8) and one narrow peak of height 1.0. Each agent proposes a small move and keeps it if the score rises. Averages are over 60 seeded runs. In this toy the heartbeat is worth much more than the shared list; the paper attributes its gains to reusing knowledge and to multi-agent exploration together.

Switch both off and the team ends near 0.8: every agent climbs its own hill and stops there. Turn the heartbeat on and the average jumps toward 0.9. Add shared memory and it creeps a little higher, because jumps no longer waste time on hills a teammate already searched. In the lecture’s real task, the memory holds more than places. It holds notes, ideas and working code.

The results on the slide

The task comes from Anthropic’s kernel engineering task. A kernel is a small program that runs on a GPU, and a cycle is one tick of the chip’s clock. Write a kernel that finishes in as few cycles as possible, starting from a baseline of about 147,734 cycles. Fewer cycles is better, like a lower lap time. The score is the baseline divided by the cycles. All methods used Claude Opus 4.6.

MethodBest cyclesSpeedupNote
Best known (Anthropic)1,363108.4xThe bar to beat
OpenEvolve2,74053.9x363 evaluations, 3% of them improved (12 of 363)
CORAL, 1 agent1,350109.4x56 evaluations, 43% improved (24 of 56)
CORAL, 4 agents1,103133.9x596 evaluations

Read the table in two bites. One CORAL agent already matched the best known result with only 56 evaluations, where OpenEvolve spent 363 and stopped far behind. Four agents then pushed the score from 1,363 to 1,103 cycles, about 19% fewer, which the slide calls beating the previous state of the art by 20%. Across the paper’s ten state-of-the-art results, the abstract reports a 3 to 10 times higher improvement rate than fixed evolutionary baselines. The slide lists three fields this reaches: operations research, systems engineering and scientific discovery.

A worked example: reading the table in numbers

Start with the speedups. The score is the baseline divided by the cycles. 147,734 / 1,363 = 108.4, so the best known result is a 108-fold speedup. 147,734 / 1,350 = 109.4, so one CORAL agent matches it. 147,734 / 1,103 = 133.9 for the team of four. The team cut (1,363 − 1,103) / 1,363 = 19.1% of the best known cycles.

Now the waste. OpenEvolve improved on 12 of 363 evaluations, which is 3.3%. One CORAL agent improved on 24 of 56, which is 43%. Divide the other way: OpenEvolve needed about 30 evaluations per improvement, and one CORAL agent about 2.3. That is a 13-fold gap in how often an evaluation pays. It fits the paper’s claim of a 3 to 10 times higher improvement rate across its tasks.

Why would a free agent waste fewer evaluations? Because it can decide not to evaluate. It can read the code, run a cheap test, rule out a bad idea and only then ask the judge. A fixed loop evaluates everything it proposes, since it cannot tell.

Realisation: what the shared memory holds

Think of the shared memory as a folder every agent can open. It holds notes (“splitting the batch in two helped by 4%”), skills (small reusable scripts) and the attempts so far with their scores. An agent that starts a new run reads the folder first, so it does not repeat a failed idea. A teammate’s breakthrough appears in its folder the next time it looks, with no one telling it.

Because the agents run asynchronously, there is no round at which they all meet. Each reads, works and writes when it is ready. The heartbeat is the only fixed rhythm: a timer, not a schedule of tasks.

An agent has gone five rounds without improving. Which CORAL idea steps in, and what does it do?

Chapter 7

What Makes a Loop Compound

Tune retention, entropy and grounding, and see which one failure each knob guards against

A savings account earns interest. A leaky bucket does not, however fast you pour. Two systems can look the same on day one, with money going in and numbers going up. Only one of them compounds.

The lecture ends its self-evolving section with a goal: agents that constantly verify their knowledge and improve their capabilities over time, beyond static human supervision. It points to a blog post, The Compounding Loop (quao627.github.io/blog/self-evolving-agents, April 2026). The post surveys 66 works from 2022 to 2026, and its main claim is that “self-evolving” hides real structural differences. Many systems use the same parts: a language model that mutates, an archive and an automatic evaluator. They differ in what they change and how they wire the loop. Two questions decide whether a loop compounds.

The shape of the loop

The first question is the loop’s topology: its shape. The post lists five, and each includes the one before it.

TopologyShapeExample in this lesson
T1 open loopNo feedback comes backA prompt written once
T2 single targetOne loop changes one targetAlphaEvolve, MEM1 (most systems sit here)
T3 self-referentialThe evolver and its target are the same systemThe Darwin Gödel Machine rewrites its own code
T4 co-evolutionA proposer and a solver improve each otherAbsolute Zero, SPIN and WebRL (a proposer and a solver)
T5 nestedA meta-loop improves the loopPromptBreeder evolves its task prompts and its mutation prompts

The post warns that many claims of recursive self-improvement are really T2. A system that gets better at a task is not necessarily getting better at getting better.

The three forces

The second question is about forces. The post says a loop compounds only when three forces are all present and strong. Think of them as three questions about any loop.

Retention asks: does the loop keep what it learned? A good change must stay. When retention is weak, new learning overwrites old, and the loop suffers catastrophic forgetting. AlphaEvolve’s program database, and CORAL’s shared memory, are retention devices.

Entropy asks: does the loop keep bringing in something new? Without fresh variation or new information, the loop converges, and every new round looks like the last. This is mode collapse. The post also names the quiet version: if nothing new enters, a loop is just test-time scaling dressed as evolution, meaning more samples from the same model.

Grounding asks: is quality measured by something outside the loop? A test, a simulator, a proof checker, a measured cycle count. When grounding is weak, the loop drifts. It starts to chase its own scores, which is reward hacking. The post says self-judgement, where the model grades its own work, is the weakest form.

Now turn the three knobs yourself. Each point on the chart is a loop run for 100 rounds. The pale line is the score the loop reports. The solid line is the true quality, which we can see only because this is a toy.

Retention, entropy, grounding

Pick a preset, then move the knobs. Watch the gap between the reported score and the true quality, and where the true line flattens or falls.

0.90
0.80
0.99

Illustrative toy, not data from the blog. Each round a proposal is either an honest edit (a random change, smaller when entropy is low and when quality is already high) or an attempt to game the score (it adds 0.04 to the reported score and costs 0.02 of true quality). Grounding is the chance the judge catches a gaming attempt. Weak retention randomly erases part of the gains. Curves are means of 40 seeded runs.

Press the four presets in turn. The healthy loop climbs to a true quality near 0.7, and the two lines stay close. With low retention the line stalls near 0.4: every gain is partly erased. With low entropy it also ends near 0.4, since every proposal is a tiny variation. With low grounding the reported line shoots up to 1.0 while the true line stays low. That last picture is the most dangerous, because the loop’s own dashboard says everything is fine.

Failure modes, as symptom, measurement and fix

Forgetting. The symptom is that old skills disappear when new ones arrive. Measure it by re-running an old test set every few rounds. The fix is an archive that keeps everything, as in the Darwin Gödel Machine, where the full archive keeps bad self-edits from wiping out progress.

Collapse. The symptom is a score line that stops moving while the proposals look alike. Measure the diversity of the last fifty proposals. The fix is deliberate variation: parents that are not the best, separate islands, or new data from outside.

Drift. The symptom is a rising reported score with no real gain. Measure by checking a sample of results against a judge the loop cannot touch. The fix is a stronger external check, and walls that stop agents editing the evaluator, as CORAL does.

What the post says is still open

The field works best where verifiers are cheap: code and mathematics. Taking the loop to messy domains is the main open problem. Self-referential and co-evolving loops have existence proofs but no theory of stability. Gains kept in context are limited by retrieval, and gains written into weights may plateau within a few rounds. AlphaEvolve’s discoveries do not carry between campaigns. And no system has yet shown that a nested meta-loop gives a lasting speed-up. The post calls AlphaEvolve a Gemini amplifier, not a Gemini transcender: its ceiling is set by the base model.

A worked example: how a gamed score passes the judge

Use the numbers behind the device. In each round, 40% of proposals are attempts to game the score, and the judge catches a gaming attempt with probability equal to the grounding value. At grounding 0.99, the share of rounds in which a hack slips through is 0.4 × 0.01 = 0.4%. Over 100 rounds that is 0.4 hacks. Each costs 0.02 of true quality, so the damage is about 0.01.

Drop grounding to 0.1. Now 0.4 × 0.9 = 36% of rounds let a hack through. Over 100 rounds that is 36 hacks. Each adds 0.04 to the reported score and takes 0.02 from the true quality. The reported score would climb by 1.44, far past its ceiling of 1.0, so it saturates early. The true quality loses 0.72, which pins it near the floor. The loop’s own dashboard reads perfect while the real result is poor.

The gap between those two lines is the quantity to track in any real system. Compute it on a sample the loop never trains on. If the gap grows, stop and fix the judge before spending another evaluation.

Reading a new paper with the three forces

Use the forces as three questions. Where does this system keep its gains, and could a new gain overwrite an old one? Where does fresh variation come from: a larger model, new data, a second agent? And who checks the result: a test, a simulator, a proof, or the agent itself? A paper that answers all three clearly has probably built a loop that compounds. A paper that is vague on one is telling you where it will break.

A self-evolving agent grades its own work. Its scores climb for weeks, but users report no improvement. Which force is weakest?

Chapter 8

Build the Loop

Write a working evolver in about forty lines, and watch each part do its job on a task you can check by hand

You now know the parts: a proposer, a judge, an archive, a rule for choosing parents and a way to apply an edit. A loop is only real when it runs. This chapter builds one, shows exactly what moves between the parts, and runs it live on a task small enough to verify with a pencil.

The contract of each part

Six small pieces make the loop. Write each as a function with a clear input and output, and the whole system fits in your head.

  1. evaluate(program) → dict. Runs a candidate in a sandbox and returns scores, for example {"score": 0.62, "error": None}. It must have a timeout, and it must never raise.
  2. archive. A list of records {id, code, score, parent}. Every candidate goes in, even a bad one, so the tree stays whole.
  3. pick_parent(archive) → record. The exploit and explore rule from Chapter 4.
  4. build_prompt(parent, others) → str. The parent’s code and score, plus one or two other good programs for inspiration, plus the task and the reply format.
  5. propose(prompt) → diff. One call to a language model. Text in, a SEARCH/REPLACE block out.
  6. apply(code, diff) → code. A plain string replacement. If the SEARCH text is not found, the diff is rejected.

The prompt is where context evolves. It is the only thing the model sees, so what you put in it is the system’s memory. Putting two or more strong programs side by side lets the model combine their ideas, which plays the role of crossover in classic evolution.

The loop in code

python: the whole evolverimport random, subprocess, json

def evaluate(code, timeout=5):               # the judge: lives OUTSIDE the agent
    try:
        out = subprocess.run(["python", "judge.py"], input=code, text=True,
                             capture_output=True, timeout=timeout)
        return json.loads(out.stdout)           # {"score": 0.62}
    except Exception as e:
        return {"score": 0.0, "error": str(e)}   # a crash costs one evaluation

def pick_parent(archive):
    top = sorted(archive, key=lambda r: -r["score"])[:5]
    return top[0] if random.random() < 0.7 else random.choice(top)

def build_prompt(parent, archive, task):
    others = random.sample(archive, min(2, len(archive)))
    shown = "\n\n".join(f"# score {r['score']:.3f}\n{r['code']}" for r in [parent] + others)
    return f"{task}\nPrograms so far:\n{shown}\nImprove the first one. Reply with a SEARCH/REPLACE block."

def apply_diff(code, diff):
    old, new = parse_search_replace(diff)       # split on the SEARCH / ======= / REPLACE markers
    return code.replace(old, new, 1) if old in code else None

def evolve(seed_code, task, llm, budget=200):
    archive = [{"id": 0, "code": seed_code, "parent": None, **evaluate(seed_code)}]
    for i in range(1, budget):
        parent = pick_parent(archive)
        diff = llm(build_prompt(parent, archive, task))        # the only model call
        child = apply_diff(parent["code"], diff)
        if child is None: continue                          # bad diff: skip, costs no judge call
        archive.append({"id": i, "code": child, "parent": parent["id"], **evaluate(child)})
    return max(archive, key=lambda r: r["score"])

Every line of this is what the earlier chapters named. The judge sits in a separate process, as CORAL does with its separate evaluator. A crash scores zero and the loop goes on, as in Chapter 3. The archive keeps every record with its parent, so the tree of Chapter 4 can be drawn afterwards. To add test-time training from Chapter 5, you would add one line after evaluate that rewards the model by the improvement score. To add a team from Chapter 6, run several copies of evolve that read and write one shared archive, and add a timer that interrupts a stalled copy.

Run it

In the device below the model call is replaced by a plain random edit, since your browser has no language model. Everything else is real. The program is three numbers, a, b and c, in the formula a·x² + b·x + c. The judge compares its output with five data points and returns 1 / (1 + mean squared error). You will see the exact prompt and the exact reply in the panel at each step.

Run the evolver

Press Step to run one loop turn. The panel shows the prompt sent to the proposer, its reply, and the judge’s verdict. The table lists the five best programs in the archive.

The proposer here is a seeded random edit (change one of a, b or c by one of 4 step sizes: −2, −1, +1 or +2), standing in for the language model. The judge is real: it scores five points of the curve 3x² − 2x + 1. A perfect score of 1.00 means the numbers are exactly 3, −2 and 1.

Run about twenty turns. You will see a stretch of quick gains, a few long runs of misses, and then an exact answer. The count of turns it takes is your sample budget, the real currency of every system in this lesson. Each turn in a real system costs one model call and one judge run.

Failure modes of your first evolver

The hung judge. Symptom: the loop freezes. Measurement: the longest evaluation time in the archive. Fix: a hard timeout and a separate process, as in the code. The unparseable reply. Symptom: many turns with no child. Measurement: the share of diffs rejected by apply_diff. Fix: show the model the exact reply format and one example. The cheat. Symptom: a score of 1.00 from a program that does nothing useful. Measurement: run it on held-out inputs. Fix: the judge must test more than the model has seen.

A worked example: what a run costs

The budget in the code is 200 turns. Say each turn sends a prompt of about 1,500 tokens and receives a reply of about 200 tokens, and the judge takes 5 seconds. These numbers are illustrative, not from any paper. The model reads 200 × 1,500 = 300,000 tokens and writes 200 × 200 = 40,000. The judge runs for 200 × 5 = 1,000 seconds, about 17 minutes.

Run four copies in parallel on one shared archive and the judge time drops to about 4 minutes of wall-clock time. The token bill stays the same, so a team is not cheaper, only faster. Chapter 6’s result is subtler: the team found a better answer, not just a quicker one, because the copies explored different places.

This arithmetic tells you where to spend effort. If the judge is slow, a cascade or a faster simulator pays most. If tokens dominate, shorten the prompt: show fewer examples, or compress the archive in it. If most turns are rejected diffs, fix the reply format.

From the toy to a language model

Replace the random edit in the device with a call to a model and nothing else changes. The prompt grows from one line to a page: the task, the parent code and score, two other programs for inspiration, and the reply format. The reply grows from one number to a real diff. The judge grows from five points to a proper test suite or simulator. The archive, the parent rule and the loop stay as you see them. That is why a forty-line evolver is a fair model of the real thing, and why the hard parts are the judge and the prompt.

In the evolver, a proposed diff names text that is not in the parent program. What should the loop do?

Chapter 9

Field Guide

Keep the numbers, the terms, a checklist and the core code on one page, and find where to go next

The one-paragraph summary

A self-evolving agent runs a loop of four steps: retrieve, propose, evaluate and update. What changes can be the context (MEM1 rewrites one small state each turn), the harness, the model (TTT-Discover and ThetaEvolve train weights at test time on the improvement score) or the environment. In AlphaEvolve and OpenEvolve a language model is the mutation step and an outside evaluator is the judge. Programs form a tree in which most edits fail and a few chain into stepping stones. CORAL hands the loop to long-running agents that specialise, share memory and receive a heartbeat. A loop compounds only if it has retention, entropy and grounding, all three.

The numbers that matter

WhatNumberWhy it matters
MEM1-7B vs Qwen2.5-14B-Instruct3.5 times the performance, 3.7 times less memory, on a 16-objective taskOne rewritten state beats an ever-growing prompt
AlphaEvolve, 4 by 4 complex matrices48 scalar multiplications, first gain over Strassen in 56 yearsA judged search can beat a long-standing human result
ShinkaEvolve, circle packingFewer than 150 program evaluations to beat AlphaEvolve’s solutionSample efficiency, not model size, is the lever
TTT-DiscoverUp to 2 times faster GPU kernels; a few hundred dollars per problemTraining on one problem can pay for itself
Kernel task baselineAbout 147,734 cyclesSpeedup is baseline divided by cycles
Best known vs CORAL, 4 agents1,363 cycles (108.4x) vs 1,103 cycles (133.9x)About 19% fewer cycles
CORAL, 1 agent vs OpenEvolve1,350 cycles in 56 evaluations vs 2,740 in 363Autonomy and memory pay before the team does
CORAL, ten state-of-the-art results3 to 10 times higher improvement rate than fixed baselinesFewer wasted evaluations
The compounding-loop survey66 works, 2022 to 2026, five topologies, three forcesA map for any new paper

The terms

TermMeaning
Self-evolving agentAn agent that changes itself using feedback it gathers, so the next try is better
Evaluator, judgeA function outside the agent that scores a candidate
Program database, archiveThe stored candidates with their scores and parents
Stepping stoneA weak program whose idea a later program uses
Test-time trainingChanging the weights on the problem you are solving
HeartbeatA regular nudge that makes an agent reflect or change direction
Retention, entropy, groundingKeep gains, bring in the new, check against the outside

A checklist before you build one

  1. Judge first. Can a script score any candidate in seconds, with no human? If not, stop here.
  2. Wall off the judge. The agent must not be able to edit the evaluator or see its hidden tests.
  3. Keep everything. Store every candidate and its parent, including the failures.
  4. Force variety. Pick some parents that are not the best, and watch the share of children that beat their parents.
  5. Budget the evaluations. Fix a number in advance, and plot best score against it.
  6. Audit against the outside. On a schedule, score a sample with a judge the loop never sees.

The core in code

python: three lines that carry the lesson# 1. the loop (Chapters 2 and 3): retrieve, propose, evaluate, update
child = apply_diff(parent.code, llm(build_prompt(parent, archive)))
archive.append(Record(child, parent=parent.id, **evaluate(child)))      # the judge is outside the agent

# 2. test-time training (Chapter 5): reward = how much the best score improved
reward = max(0, score - best_so_far)
model.update(prompt, reply, advantage=reward - baseline)

# 3. a heartbeat (Chapter 6): reflect when stalled
if agent.rounds_since_improvement >= 5:
    agent.interrupt("What have you tried? What does shared memory say? Pick a new direction.")

Where it sits in the field

This is the last piece of the course’s advanced tour, and it connects back to multimodal reasoning, where the long reasoning context first became a problem. Self-evolving loops are the fastest-moving part of agent research, and the blog’s open problems, judges beyond code and maths, stable self-referential loops and gains that transfer, are where the next papers will land.

Keep going

Credit

This lesson follows Lecture 14.1 of MIT Multimodal AI (Spring 2026), taught by Paul Liang and the MIT Multisensory Intelligence group; here are the lecture slides. All explanations and devices are our own. Sources: the blog post on self-evolving AI; AlphaEvolve (Novikov et al., 2025); CORAL (Qu et al., 2026); MEM1 (Zhou et al., ICLR 2026); TTT-Discover (Yuksekgonul et al., 2026). Every toy number is labelled illustrative.

The takeaway. A self-evolving agent is a loop with a memory, a proposer and a judge. It compounds when it keeps what it gains, keeps bringing in something new, and measures itself against something outside itself. Take away any one and it forgets, collapses or fools itself.
You must build a self-evolving loop for a new task. Which first step does this lesson support?

Now press Present or Teach and explain the loop from memory: its four steps, why most edits fail and a few matter, what the heartbeat and the shared memory add, and the three forces. Then go back to the instrument at the top and run the four agents again.

MMAI Lecture 14.1: Self-Evolving AI
The course site · Lecture slides · Blog post on self-evolving AI · CORAL · AlphaEvolve · Back to Gleams