How To Build Self-Improving AI Agents with Claude (Stanford's Method)

summarized

TLDR

Stanford's method for self-improving AI agents, as distilled into a four-step playbook, requires four separate agents—generator, verifier, coach, and a loop—with the critical rule that the verifier must be read-only to prevent test gaming. The recommended autonomy level for most non-technical work is level two, where AI suggests improvements but a human approves, not full autonomy.

Key points

The generator agent has a specific job description and must include a reason for each rule.

The verifier agent is read-only and uses an answer key to grade the generator's outputs.

The coach agent proposes one change per draft in a separate candidate file without modifying the live generator.

An agent that graded itself claimed 54 improvements but 56% of changes were flat or worse.

Level two autonomy, where AI suggests improvements but a human approves, is recommended for most non-technical work.

Tools mentioned

Techniques

  • generator-verifier-coach architecture
  • answer key evaluation
  • one-change-per-draft
  • version folder
  • level 2 human-in-the-loop
Transcript (captions)

0:00 So, Stanford just released a course on how to build self-improving AI agents. But the problem is it's over 10 hours long. It's extremely technical and it's the type of video you bookmark but never

0:08 actually get around to watching. And I put together a four-step playbook that will help anyone, technical or not, build self-improving AI agents. And for each step, you're going to build

0:16 alongside me. So, make sure to pay attention. But before we do anything, we need to have a clear understanding of some key terms. So, the first is what are AI agents? You've likely heard this

0:24 term a lot, but most people don't fundamentally understand what this is. And Stanford had an explanation that really made it click for me. >> It has a goal and it will go and

0:31 interact with the environment, collect feedback and use that feedback to correct its steps. So they're basically systems that can direct their own processes, use tools and then accomplish

0:41 a goal. >> In plain English, an AI agent uses an AI model, tools, and any context it has at its disposal to get a job done, not just answer questions. And as we go into

0:52 2027, almost every tool you interact with is already some form of AI agent. So when you chat with Claude, you're talking to the main agent. It has memory of the conversation, tools it can use,

1:01 and a model that helps it do its thinking. Then if that's the main agent, you can create sub aents with different tools and different permissions. So that's AI agents. But the other piece to

1:09 understand is skills. Think of these like a recipe you can hand the agent. So if you type something liked email, your agent follows a /draft email skill recipe to complete the task. Skills can

1:19 call agents and agents can use skills, but ultimately a skill is the guide and the agent follows it. Okay, great. So, those are some key terms you need to understand. But how do we make one of

1:28 these agents self-improve itself? Well, in Stanford's course, they cover two ways. The first is retraining the model itself through fine-tuning and updating the weights. And I personally know

1:37 people who are doing this, but if you're watching this, you're likely a business owner or a highle operator. And you do not fall in this category. And the second way is update what the model

1:45 reads. And this is much simpler. And this is the approach that we're going to cover in this video. Now, in practice, you can actually do this in three ways. The first is you improve the tools the

1:52 AI agent has access to. The second is you improve the context it has and the third is improve the skills it has to work with. But in order to have any sort of self-improving system, first you have

2:02 to create the agent that actually does the job. And Stanford calls this the generator. So step one of the four-step process is build the generator. This first agent we're creating the

2:11 generator. It has a very specific job description that it's going to then execute. Generally for AI agents, the more specific and well-defined that job description is, the better. So, for

2:21 today's video, we're going to be building an agent that answers questions exactly how you would answer them. Basically, we're going to create an AI agent that's a clone of yourself. And

2:28 this is the pattern that I've taught hundreds of operators and founders. And there's a reason that I picked this as what we're going to cover today. The best self-improving systems have a

2:36 concrete verifiable way to check an output. And so, from Stanford's course, why is a subject like math so easy for AI? >> Now, why does this work? So, math is a

2:45 domain in which there is verifiability. So, we had an whole lecture on robust verification. So you have the ability to know which outputs are correct and which ones are not correct. So you have some

2:54 ability to actually choose the correct outputs that that can then feed into train time scaling. So this works better in domains where there is verifiability. >> Now extending from math to engineering,

3:04 engineering is also very easy. You have to find ways to verify the output. And one of the easiest source of truths is yourself. You can verify if that's how you would analyze an input. So we're

3:14 going to create a clone of ourselves and I'm going to build one called Austin GPT. So, here's a prompt that you can use to have Claude interview you and write the agent file. And all you have

3:23 to do is answer questions and it'll create the agent, which is the generator in our larger system. So, at this point, we have the generator. But an agent that can produce its own work can't

3:32 necessarily tell you whether the work is any good. And fixing that is step two, which is the part that most people skip. But before we get to that, we just built an agent that does one job really well.

3:41 But the one job that every business needs help with is finding customers, which brings us to today's video sponsor, Clay. Finding customers used to require a full sales department. You'd

3:49 have somebody who finds a leads, another person who figured out how to contact them, and another person actually reaching out. But now it's one sentence. You open Clog Code and type something

3:58 like, "Build me an email campaign that targets service businesses with a job opening for AI integrators in the last 90 days and is located within 50 mi of me." And then the Clay CLI will build

4:09 the whole outreach campaign. It'll find the companies, find the founder or decision maker, pull their contact info, research each one so you know who's actually worth reaching out to, and then

4:18 it will draft the outreach. And what makes Clay so powerful is the data it has access to, and the granularity I can go into. See, Clay connects to over 250 data providers. And by pairing that data

4:28 with these providers together, Clay has access to the best data in the world, all in one place. So, in this case, I asked for a service business with AI job openings around me, which is signal that

4:38 they're looking to hire for the problem I solve. And this is how you can be precise with your outreach without it feeling spammy. Everyone on this channel is learning to build with AI. And the

4:46 part that most people ignore is how they're actually going to get their product to paying customers because this seems so challenging. But Clay solves that because with their tooling, now a

4:54 single person can run an entire sales department directly through Claude. Now, the example I went through today is powered by Clay's new GTM agent, which is launching in beta very soon and can

5:04 already be accessed through the Clay CLI included. And the beauty is Clay is free to start and no credit card is needed. And if you sign up with the link in the description by the end of the month, my

5:12 community gets $250 worth of free credits, which can get you a lot done. So, sign up for Clay with that $250 in credits and you can start building with the Clay CLI today. Step two, build the

5:23 verifier. One question you may be asking is why can't the agent that did the work just check its own work. You can think of it like this. You're grading your agents output and the student can't mark

5:33 their own exam. And here's Stanford describing this exact concept. >> Often times getting the model to critique itself can be harder. So having a consensus of other models to critique

5:43 the model sometimes works better because the models might be overconfident in >> and this overconfidence is measured. In one study, an agent ran 54 self-improving cycles and said improved

5:53 all 54 times. But the reality is that 56% of those changes were flat or even worse. And this reminds me of the Michael Scott's world best boss mug. It's a great mug until you find out that

6:03 he bought it for himself. So, we need a second agent whose only job is to review the output. But now, building this verifier takes two parts. The first part is the answer key or the evaluation

6:14 grading criteria. And the second part is actually the verifier itself. The answer key part one is a mapping of what you want your agent to output based on specific inputs. So for code, you would

6:24 just check if it passed or failed a quantifiable test. But for non-technical knowledge work, it's a bit more nuance. And so we need to check if that Austin GPT's response align with what I would

6:36 actually say. So a straightforward way to do this is with a table. On the left will be examples of the input and then on the right I'd give the actual answer that I would provide. Claude will help

6:45 build this table and then I'll edit it directly. To make this concrete, right, it might feel a little abstract. Let's say someone asked me, "Where can I find the checkout link for a customer?" The

6:54 response would be, "Check our build partner.ai admin portal." This is a very simple example, but I want to codify ways that I would respond to my own team so that I could streamline this process

7:05 without them bugging me. And so for awesome GPT, I'm pulling the questions my team has asked me from Slack and the exact answer I gave it to build out this answer key automatically. So this prompt

7:15 goes and it grabs the 20 most common questions. Then I'd go through that list and manually review and make sure that the response is exactly how I would actually answer it. And this data set

7:24 that we're creating is called an evaluation data set. And I just call it the answer key.md. And this key is so critical to creating self-improving agents. It is a living breathing

7:34 document. So every time the agent lets me down or gets something wrong, it's not a problem. It's just a new row in the answer key for us to evaluate the effectiveness of this AI agent and this

7:45 becomes a source of truth for grading every future change. So now we understand what this answer key or this evaluation criteria is. Now we need to actually go and build the verifier. The

7:54 goal of a verifier is to answer is the answer right or wrong. And as part of this, it should never actually edit anything. That means not the answer key, not the agent. It's simply reading and

8:04 analyzing what's going on. So to create this, here's a prompt and the verifier will explain why it thinks something is wrong. And the reason matters because it's giving usable context for actually

8:14 fixing it. But what actually fixes it? Well, that brings us to the next step of the process. Step three is add the coach. At this point, there are two agents that we made. The AI generator in

8:24 step one and the verifier in step two. And this is where you're likely asking, can't the verifier just fix the generator? And the answer is no for two key reasons. The first is the score

8:34 stops actually meaning anything. If the same agent writes the fixes that grades it, it's like grading your own homework. The verifier is only trustworthy because it's read only and it has no stake in

8:44 the result. The second is it will game the test. An agent that can see the test and also write the fix learns to pass the test rather than doing the job as it's intended to. The reason we create

8:55 these tests in the first place is to help the generator do its job as best as possible. Now the natural next question, can the generator just fix itself? The answer is no. And the biggest reason is

9:04 it's editing itself as it's trying to fix itself. So you're kind of hitting a moving target and it's harder to manage. And that brings us to the third agent, the coach. The coach does something

9:14 different than both the verifier and the generator. It reads what the verifier found. It writes a draft version of the agent file, a candidate, right next to the one that currently exists. And you

9:25 never actually touch the live file that's running. So to restate that, what this coach will do is it'll essentially copy and paste the existing agent that's doing most of the work and adjusting one

9:36 thing to see if that improves the output. And the reason for this, whenever you're testing something, you want to isolate the variable that you changed. And so you have to have

9:44 something that's constant, and that's the original, the generator that you first made. Now, to actually create this, here is a prompt that will help you create a coaching agent. And this

9:53 one is specifically for my awesome GPT coach. And there are a couple of rules to call out. Again, I mentioned it previously, but one change per draft. If you change eight things, you can't tell

10:02 which one made a difference. The second is it never touches the answer key or the verifier. If you could adjust those files, the easiest way to pass the test is to just change the test. And the

10:12 third is it keeps a versions folder. This will create a history of past agents so it can learn over time. And by having three different agents, you're able to restrict permissionings. And

10:20 this is super important because you're able to alter what tools and files agents have access to programmatically. You can make it so that the coach literally can't edit the answer key or

10:30 the original generator agent. And when building systems at scale, this permissioning is very important for system design. So now at this point, you have the generator which does the task,

10:39 the verifier which grades the work, and the coach which suggests the change. And as a check-in, I do know that this system is a bit complicated. So slow down, rewatch what I said. And this is

10:49 for more complex systems. That's why it has to be a bit more complex. But it should all logically make sense as to why we're doing what we're doing. Once you're at this point, you can then

10:59 compare the coach's version versus the original version by testing across the specific use cases the generator got wrong along with all of the historical other versions. And if this coaching

11:09 candidate ends up scoring better, that brings us to the last step. And this is where you can either go simple or a bit more complex to get the output that you want. But before we get to that, if this

11:18 is your first video of mine, welcome to the channel. But if this is your second or more, you know the drill. This is our anti-slop agreement. The visuals, the testing, the hours of research that went

11:27 into this video. It's entirely built for humans by humans. So, all that I ask is you subscribe so that this content can reach more people. And for everybody who already subscribes, you are a legend.

11:37 But make sure to sign up for those post notifications. And as a thank you for all the support, every video I give away a Claude Max subscription. And this video's winner is Hail Mary Pizza. epic

11:46 handle for building an AI native business intelligence OS for SMBs. To enter this video's giveaway, comment below with what you're building, a recent feature you built, or any

11:55 problems that you're running into. As always, I love chatting with you in the comments. But let's get to step four, which is about picking your level. There are three levels of self-improvement.

12:03 Level one is you suggest the improvement. Level two is AI suggests you approve. And level three, AI improves itself without you. Everything we've covered thus far in this video is

12:12 about structuring your system to allow for any of these levels. And when people hear self-improving system, they think it's automatic by default, and that's where people default to. But the reality

12:22 is that you likely want to be in level two. See, level one is when you notice an issue, you tell Claude, and then Claude writes the rule. This works on day one, and this works for a ton of use

12:32 cases. So, don't get me wrong, this is effective. Use this one line a bunch on this channel, and I suggest you do, too. You can say directly include based on this conversation, update the skill or

12:41 agent I used so this doesn't happen again. And this is good for a lot of things, but for things that are really important, which is what we're covering with our clone, that may not be enough.

12:50 And that brings us to level two, which is the Goldilock zone. Here is where the generator, the verifier, and the coach run on their own against your past outputs. They'll suggest an improvement,

12:58 and they'll leave you a decision, and you get to choose whether or not to approve the change. It doesn't approve it on its own, but it does suggest how to improve it. And here's one of the

13:07 last prompts that you'll need. And this will create a full loop where it goes through and it suggests an improvement and then you end up approving it. Now, if you want an even simpler level two

13:16 approach to this, and this is something that I also use is within the build partner.AI plugin, there is a mod that lives on my machine and it suggests improvements in real time based on my

13:26 conversation. And then I can either approve or deny it if I think it's the right direction. Now, that's for much simpler systems, but it is very effective still for having a level two

13:35 self-improving system. Then there's level three, which is the most tempting. To do this properly, you have to have all of the infrastructure in place. And this is where you loop through the

13:43 generator, the verifier, and the coach until all the evaluation criteria is fixed. Now, to do this, you can run this prompt, which will loop until it fixes itself automatically, or it hits 10

13:54 iterations. The reason that I say to stop at 10 iterations is to save you tokens and to stop this infinite loop which will just cost you time and money. Now, this is very intriguing, but check

14:04 out this comment from Zuben at Weights and Biases about exactly this. It's really easy to go like auto mode, but it doesn't absolve yourself of the thought behind how we want to make improvements.

14:14 >> This statement resonated with me, especially for non-technical work. Having AI loop through the fixes can be a trap that leads you to no longer understanding how your agent works and

14:25 it creates unpredictable outcomes because you don't know what's going on. And that happens because it changes and modifies automatically. So the right level of this self-improving system

14:36 could change depending on the work that you're doing. If you have an extremely verifiable pass or fail test case, level three can work. And this is primarily for technal work. And that's where

14:45 you'll see most people creating these level three self-improving systems. But if you're struggling finding an exact measurable evaluation criteria for your verifier that we created in step two,

14:54 then you're going to struggle in practice creating a level three self-improving system. So in this case, stay at level two where your taste can be the final sign off. And in terms of

15:04 level one, that's where you're just telling the AI system to improve based on something you noticed. Just do that whenever you see it happening. And again, here is the prompt that I love

15:12 using in my day-to-day. So, let's zoom out for a second because there is a bigger idea here than just the four things we built. If we want AI agents that actually get better over time, you

15:22 need four pieces working together. Step one is the generator. That is a clear job description with a reason behind every rule. Step two is the verifier. This is an independent readonly agent

15:33 that checks the work against an answer key. Step three, that's the coach, an agent that proposes improvements in a separate candidate file without touching the version that's already working. And

15:44 then step four is pick your level of self-improving system. Decide how much autonomy you're comfortable giving the system. And for most people, level two is the sweet spot. Now, that is the

15:54 whole process, but here's the mental model I want you to take away. Self-improving AI doesn't mean letting AI rewrite itself until it's magically smarter. It means building a feedback

16:03 loop where the intelligence is in how you design the system and that includes the decisions that you let AI make and the decisions that you make yourself. Now, Stanford's course goes much deeper

16:12 into the technical side, but 99% of people don't need to know all those details. Claude will handle the technicals and what I covered in this video gives you the strategic direction

16:21 to build a system yourself. So, go run the prompts yourself so you can build your own version of Austin GPT. But no matter what you're building, you're likely going to run into a token

16:30 constraint and not know which model to choose for which agent. So to solve this problem, I made this video which will teach you everything you need to know about clawed models. Now, if you're new

16:39 here, my name is Austin Maresy and welcome to the channel. I'll see you in the next video. Peace.

Frontier News · by Hyperjump Technology