Ray Fu, ex-Meta senior engineer and AI automation educator

Ray Fu

I'm an Ex Meta Senior Engineer that makes content and teaches OpenClaw and AI Automations.

stan.store/raycfu

How to 5x Your Loop System with Bilevel Loops

The Bilevel Loop

Don't want to figure this out alone? I walk members through every step inside the community. Join the Skool → skool.com/raycfu

Two researchers published this in March 2026 and got 5 times better results on the same benchmark Karpathy used, with the same AI model in both seats. No smarter model, no extra intelligence anywhere. The entire gain came from the structure.

Setup takes about 30 minutes on top of a loop you already have.

The Problem This Solves

The Rut

 

Even a great loop develops habits.

Your AI has instincts about what kinds of ideas are worth trying, and it keeps returning to those same instincts, over and over, long after they stopped producing anything. So your loop runs 500 experiments, but really it tried the same 10 types of ideas 50 times each. It looks productive. The logs are full. The numbers stopped moving three days ago.

And the loop cannot see this about itself, because the thing that is stuck is the thing doing the looking. That is the whole problem, and it is why simply running your loop longer stops helping at a certain point.

The fix is a second loop whose only job is watching the first one.

The Shape of It: Worker and Coach

The inner loop is the worker. It does exactly what your loop already does: propose a change, run it, score it, keep or discard, repeat. Nothing about it changes.

The outer loop is the coach. It never touches the actual work. It reads what the worker has been trying, finds the pattern the worker keeps falling into, and then rewrites the worker's instructions to force exploration in directions the worker's instincts avoid. Then it sends the worker back in with the new playbook.

Worker works. Coach watches. Coach adjusts the playbook. Worker works again. That is the entire invention.

The key rule: the coach changes how the worker searches, never what counts as success. The scoring stays locked, because a coach that can move the goalposts will eventually just move the goalposts.

What You Need First

The Three Files

 

A working single loop, with three things in place, because the coach has nothing to read without them.

A real verifier, a test, a metric, a build, something that passes or fails without your opinion. A log, a running record of every attempt: what was tried, what score it got, kept or discarded. And a stop condition, so nothing runs forever.

If your current loop does not write a log of attempts, add that before anything else. The log is the coach's only source of information, and a coach with no log is just another opinion.

Step 1: Make the Worker's Playbook a Separate File

Right now your loop's instructions are probably baked into your loop prompt. Pull the "how to search for ideas" part out into its own file, call it playbook.md, and have your loop read it at the start of every run.

This is the one structural change that makes everything else possible, because the coach edits this file and nothing else. Your playbook starts simple, something like:

# PLAYBOOK
## How to pick the next thing to try
- Prefer small changes that can be measured independently.
- Try the most likely improvement first.

## Directions to explore
- [whatever your loop should be considering]

## Do not try
- [anything already ruled out]

That is it for now. The coach fills this file in over time, and watching it do that is the interesting part.

Step 2: Give the Worker a Log It Actually Writes To

Every attempt gets one line in attempts.log: what was tried, the score, and whether it was kept. Add this instruction to your worker prompt:

After every attempt, append one line to attempts.log in this exact format: timestamp, a one-sentence description of what you tried, the category of idea it belongs to, the score it produced, and KEPT or DISCARDED. Never edit or delete previous lines. Never summarize, one line per attempt, always.

The category field is what makes the coach's job possible. It is how the pattern becomes visible.

Step 3: Write the Coach

The Coach Cycle

 

The coach runs after every 15 to 25 worker attempts, not after every single one, because it needs enough history to see a pattern. Here is the coach prompt:

You are the coach. You do not do the work and you never touch the scoring.

Read attempts.log and the current playbook.md. Your job is to find what the worker is stuck on and fix how it searches.

Answer these in order:
1. Which categories of ideas has the worker tried most often? Count them.
2. Which categories produced improvements, and which produced nothing across many attempts?
3. What is the worker clearly avoiding or has never tried at all?
4. Is the score still moving? If the last 10 attempts produced no improvement, say so plainly.

Then rewrite playbook.md:
- Move exhausted categories into the "Do not try" section, with the evidence: how many attempts, zero results.
- Add 2 to 3 specific new directions the worker has not explored, chosen because they are different in kind from what it has been doing, not just variations of it.
- Keep the file under 40 lines. Delete guidance that is no longer earning its place.

Rules: never change what counts as success. Never edit attempts.log. If the worker is genuinely making progress, say so and change nothing, a coach that meddles with a working search makes it worse.

Output the new playbook.md and a two-sentence explanation of what you changed and why.

That last rule matters more than it sounds. A coach that feels obligated to find something every cycle will start breaking a loop that was working fine.

Step 4: Wire the Two Together

Now connect them so it runs without you. The pattern:

Run the worker until it has logged 20 attempts. Run the coach once. Let the coach rewrite playbook.md. Run the worker again, reading the new playbook. Repeat.

If your loop runs on a schedule, add a coach run to the schedule at roughly one coach run per 20 worker attempts. If you run it by hand, just run the coach when you notice the score has flatlined.

Ask your AI to build this scheduling for you: describe the two prompts, the log file, and the cadence, and have it write the script that alternates them.

Step 5: Watch the Right Number

Watch This Number

 

Do not judge this by whether the coach's suggestions sound smart. Judge it by one thing: is the score still moving after the point where your single loop used to flatline?

Keep a simple record of your best score at each coach cycle. If the number resumes climbing after a coach intervention, the structure is working for your problem. If three coach cycles produce nothing, your ceiling is somewhere else, usually the verifier is too coarse to detect real improvement, or the problem genuinely has no more room in it.

That honesty is the point of having a deterministic score in the first place.

The Honest Caveat

The 5x number comes from one paper, on one specific benchmark, with a well-defined objective and a clean measurement. It is a striking result and the idea underneath it is sound, an agent stuck in its own priors cannot diagnose itself. But it has not been replicated across a wide range of tasks yet, and your mileage on your particular problem is unknown until you measure it.

So treat the multiplier as a headline, and treat your own score curve as the truth. The reason to build this is not the number, it is that when your loop stalls you now have a mechanism instead of a shrug.

When Not to Build This

When Not to Build It

 

Skip it if your single loop is still improving, add the coach when the score flatlines, not before. Skip it if you do not have an automated verifier, since without a real score the coach is just two AIs agreeing with each other. Skip it if the task runs less than weekly, because the setup will not pay itself back. And skip it if your token budget is tight, this doubles the reasoning cost of every cycle.

Every one of those is a reason to run your normal loop and be happy with it.

The Recap

Pull your loop's search instructions into playbook.md. Make the worker log every attempt with a category and a score. Run the coach every 20 attempts to read the log, find the rut, and rewrite the playbook. Never let the coach touch the scoring. Then watch whether your score keeps climbing past the point it used to stall.

One AI does the work. A second AI fixes how the first one thinks. That is the whole idea, and it works on anything you can measure.

Don't want to figure this out alone? I walk members through every step inside the community. Join the Skool → skool.com/raycfu