YouTubeFeed

Loop Engineering from First Principles — Kyle Mistele, HumanLayer

Summary

Kyle Mistele, co-founder of HumanLayer, opens with a blunt critique of the industry’s current obsession with “loops”: piping a prompt to a coding agent in a bash loop produces 40,000-line pull requests that nobody reviews, and that nobody can trust. He walks through the hype cycle — Peter Steinberger’s “stop prompting, start looping,” OpenDevin, Boris Cherny’s comment that writing loops is now his whole job as a Claude Code creator — and contrasts it with the reality that this stuff is expensive, unstable, and still not clearly working (it took six months to fix Claude Code’s terminal flicker). His argument is that loops themselves aren’t the problem; blind, non-incremental loops are. The fix is borrowed straight from control theory: a sensor measures the current state against a set point, a controller turns the measured error into a small control signal, an actuator applies it, and the system re-measures. Thermostats, Kubernetes autoscalers, infrastructure-as-code, Postgres’s autovacuum, and React’s virtual DOM all already work this way.

The bulk of the talk is a concrete walkthrough of a control loop HumanLayer runs internally to migrate their RPC API to the Effect library, one procedure at a time. AST-grep acts as the deterministic sensor that finds unmigrated procedures across their multilingual monorepo; a “disturbance dampener” enforces the new pattern on every new PR so teammates can’t silently undo the migration; a simple controller picks the smallest violation to minimize risk (and can be made smarter by pulling in telemetry about which procedures have the most errors); and an actuator agent — a CLI coding agent plus a skill built around hand-written “golden patterns” — makes the change and opens a PR. The whole loop runs as a scheduled GitHub Actions workflow.

The most practical section covers the friction that showed up once this was actually running: constantly hand-editing the skill to redirect the agent, and PRs stacking up when the team was away. Mistele’s fixes are both low-tech and effective — a version-controlled markdown feedback file that’s loaded into the agent’s context on every run and updated via a /iterate PR comment, and flow control that refuses to open a new PR while the loop’s last one is still unreviewed. The result, he argues, is a loop that improves the codebase incrementally, stays readable, and can be safely left running while the team travels or works on other things.

Highlights

”We’re still building 40,000 line PRs that nobody wants to read”

The 40,000 line PR problem

“We have this idea just kind of as an industry somehow that we can like pipe a prompt in a loop to a coding agent, and that we can build software this way, right? Maybe we’re investing a lot of time in verifiers, maybe you have six different code review agents, but at the end of the day if we’re doing this, we’re still building 40,000 line PRs that just nobody wants to read, right?” — Kyle Mistele, 0:50

Clip command
yt-dlp --download-sections "*0:50-1:37" "https://www.youtube.com/watch?v=xIt_mTQp6mY" --force-keyframes-at-cuts --merge-output-format mp4 -o "40000-line-prs.mp4"

”It took six months to fix the Claude Code terminal flicker”

Is the generated code any good?

“It took six months to fix the Claude code terminal flicker. The Open Code team wrote a renderer in a fraction of that time. And Open Claude, of course, also notoriously has stability issues.” — Kyle Mistele, 3:30

Clip command
yt-dlp --download-sections "*3:30-4:06" "https://www.youtube.com/watch?v=xIt_mTQp6mY" --force-keyframes-at-cuts --merge-output-format mp4 -o "six-months-terminal-flicker.mp4"

”A thermostat uses a control loop”

Control theory, explained with air conditioning

“A thermostat uses a control loop, right? For any of our European friends in the audience, this is part of something we have here in the states. It’s called air conditioning. And uh, most of us probably actually use control loops on a daily basis, right? Kubernetes autoscaling systems are built on control loops. Infrastructure as code uses a desired state, current state, iterative change-like control loop pattern.” — Kyle Mistele, 5:37

Clip command
yt-dlp --download-sections "*5:37-6:30" "https://www.youtube.com/watch?v=xIt_mTQp6mY" --force-keyframes-at-cuts --merge-output-format mp4 -o "thermostat-control-loop.mp4"

”Golden patterns” and the actuator agent

Building the actuator

“At Human Layer, we like to build out what we call golden patterns by hand before setting the agent loose. These are just like idiomatic handwritten examples for the agent to follow because they’re just pattern replicators and otherwise you’re getting what’s in the docs or what the agent knows from the internet.” — Kyle Mistele, 12:30

Clip command
yt-dlp --download-sections "*12:30-13:23" "https://www.youtube.com/watch?v=xIt_mTQp6mY" --force-keyframes-at-cuts --merge-output-format mp4 -o "golden-patterns-actuator.mp4"

”No stacking, no duplication, hopefully no conflicts”

Flow control stops PRs from piling up

“This way we have exactly one PR at most open per loop at a time, no stacking, no duplication, hopefully no conflicts.” — Kyle Mistele, 16:15

Clip command
yt-dlp --download-sections "*16:15-16:56" "https://www.youtube.com/watch?v=xIt_mTQp6mY" --force-keyframes-at-cuts --merge-output-format mp4 -o "no-stacking-no-duplication.mp4"

Key Points

  • The 40,000 line PR problem (0:50) - Piping a prompt into a loop still produces giant, unreviewable PRs even with lots of verifiers and review agents.
  • Replit isn’t the target (1:13) - Fine for solo/non-critical work, but most teams building on shared, regulated codebases don’t fit that box.
  • The hype cycle (1:56) - Peter Steinberger’s “design loops that prompt agents” post, OpenDevin, and Boris Cherny (Claude Code’s creator) saying writing loops is now his whole job.
  • “It’s loops all the way down” (2:18) - OpenDevin’s loops build, review, merge, and release code — and there are loops to fix bugs in those loops.
  • Code becomes read-only (3:00) - The thesis at a recent frontier-lab conference: so much code is produced nobody reads any of it, moving 10x faster than teams that do.
  • Bad code is expensive now (3:41) - Referencing Matt Pocock: bad code costs more in the age of agents than at any point before, if you’re not a frontier lab with an unlimited token budget.
  • The reframe: still loops, but readable ones (4:06) - Loops that make code easier to read because the loop itself is what’s improving it.
  • Control theory 101 (4:41) - Sensor measures current state, set point defines desired state, controller turns the error into a control signal, actuator applies it, and the system re-measures.
  • Everyday control loops (5:37) - Thermostats, Kubernetes autoscaling, infrastructure-as-code, Postgres autovacuum, and React’s virtual DOM.
  • Blind Ralph loops vs. real control loops (6:30) - The best “Ralph” loops (per Jeff Huntley) already apply control theory; a plain bash loop isn’t incremental.
  • Building sensors (7:05) - Can be strictly deterministic (ESLint, AST-grep, Packwork) or non-deterministic (an agent plus a skill), or a pipeline combining both.
  • The internal example: migrating to Effect (9:13) - HumanLayer is incrementally migrating its RPC API to the Effect library, one procedure at a time.
  • AST-grep as the sensor (9:51) - Language-agnostic, out-of-band from TypeScript config/ESLint (which agents have been caught disabling inline), and works across a multilingual monorepo.
  • The disturbance dampener (10:47) - A one-time full scan on main, tracked in version control, gates every new PR so teammates’ new code can’t undo the migration.
  • Designing the controller (11:22) - Simplest version deterministically picks the smallest unmigrated procedure; can be made agentic, though Mistele is skeptical of sending an agent to do deterministic code’s job.
  • Telemetry-informed control signals (12:00) - Feed the actuator not just “migrate this procedure” but also error/instrumentation gaps so the migration actually improves the code.
  • The actuator: agent + skill + golden patterns (12:30) - Hand-written idiomatic examples keep the agent from defaulting to generic docs-knowledge patterns.
  • Running it in CI (13:23) - GitHub Actions/GitLab/CircleCI already have code access, secrets, and scheduling — run one loop iteration daily.
  • The feedback file (13:54) - A version-controlled markdown file loaded into the actuator’s context every run; a /iterate PR comment triggers the agent to fix the code and update the file.
  • Flow control (15:40) - Each loop checks whether its last labeled PR is still open before running again — no human review yet means no new work piles up.
  • Speeding up the loop (16:25) - 150 procedures at one-a-day is six months; batch three-to-five per run, or fan out one PR per teammate.

Mentions

Companies

  • HumanLayer (0:27) - Kyle Mistele’s company; the internal Effect migration loop is HumanLayer’s own.
  • Replit (1:13) - Cited as a sharp tool for solo, non-critical work — not the target audience for this talk.
  • OpenDevin (2:18) - Notoriously built entirely on loops, including loops to fix bugs in other loops.
  • Anthropic (2:33) - Boris Cherny, creator of Claude Code, cited on loop-writing as his job now.
  • React Doctor (7:36) - Maker of Aiden, a hybrid sensor/controller tool for catching React anti-patterns.
  • GitHub / GitLab / CircleCI (13:23) - Recommended CI platforms for running loop workflows, since they already have code access, secrets, and scheduling.

Products & Technologies

  • Claude Code (2:33) - Coding agent whose creator now spends his time writing loops to prompt it.
  • Effect (9:13) - TypeScript library HumanLayer is incrementally migrating its RPC API to.
  • AST-grep (9:51) - Language-agnostic structural search tool used as the loop’s deterministic sensor.
  • ESLint (7:05) - Cited as a deterministic sensor option, though agents have been caught disabling its rules inline.
  • Aiden (7:36) - React Doctor’s tool acting as a hybrid sensor/controller for React code quality.
  • Kubernetes (5:37) - Autoscaling cited as an everyday control-loop example.
  • Postgres (5:37) - Autovacuum cited as another control-loop example.
  • React (6:00) - Virtual DOM cited as an approximate control loop.

People

  • Kyle Mistele (0:27) - Speaker; co-founder of HumanLayer.
  • Peter Steinberger (1:56) - Said engineers should design loops that prompt agents rather than prompting agents directly.
  • Boris Cherny (2:33) - Creator of Claude Code; says writing loops to prompt Claude is now his whole job.
  • Jeff Huntley (“Ralph”) (6:39) - Creator of the “Ralph” loop pattern, described as a teaching device often taken too literally.
  • Matt Pocock (3:41) - Cited on the rising cost of bad code in the age of agents.

Surprising Quotes

“It’s loops all the way down.” — Kyle Mistele, 2:18

“We’re just gonna have like swarms of agents designing loops to prompt agents building swarms for loops, and like, I don’t know, somewhere we’re like writing production code, I assume.” — Kyle Mistele, 2:33

“The syntax is really weird, we’re psychos, we really like it, it’s not for everybody, that’s okay.” — Kyle Mistele, 9:30

“I don’t think you should ever send an agent to do deterministic code’s job, but you certainly can.” — Kyle Mistele, 11:37

“No human reviewed the last output, so there’s no reason to stack up even more work for humans to review.” — Kyle Mistele, 15:40

Transcript

Kyle Mistele: 0:27 Hey everybody. My name’s Kyle, I’m co-founder of a company called HumanLayer. And I’m here to talk about loops. I think we’ve all been building loops lately. And I realized recently, I think we’re all doing it wrong. Loops are really powerful, don’t get me wrong, but so much of the discourse around them is hype-driven and just really not helpful, right?

Kyle Mistele: 0:50 We, I think we have this idea just kind of as an industry somehow that we can like pipe a prompt in a loop to a coding agent, and that we can build software this way, right? Maybe we’re investing a lot of time in verifiers, maybe you have six different code review agents, but at the end of the day if we’re doing this, we’re still building 40,000 line PRs that just nobody wants to read, right?

Kyle Mistele: 1:13 And this isn’t to throw shade at Replit, right? Replit is an innovative, it’s a sharp tool that works very well for certain types of problems. It works very well if you’re not building on a team, and it works very well if you’re not working on critical systems. But most of us are working on teams, and we don’t fit in that box.

Kyle Mistele: 1:37 So today I want to talk about how to build loops that work in large, complex code bases. For systems that have real customers, real users, real regulatory obligations, and service level agreements, and everything else that keeps us from shipping YOLO 40,000 line PRs straight to production. In other words, I want to talk about how to build loops for the real world.

Kyle Mistele: 1:56 If you’re not aware, uh, this post actually dates back to July. It went viral this past January, which is when a lot of us I think started building loops. And of course much more recently, I’m sure y’all are gonna see this slide a lot this week, but Peter Steinberger said that we shouldn’t be prompting coding agents anymore, right? We should just be designing loops that prompt our agents.

Kyle Mistele: 2:18 Of course OpenDevin notoriously built on loops. Loops build the code, loops review the code, they merge and release the code, they find and fix the bugs. There’s even loops for finding and fixing bugs in the loops that are merging the things, right? It’s loops all the way down.

Kyle Mistele: 2:33 Boris Tcherny, also the creator of Claude Code, recently said that this is his entire job as an engineer now is just writing loops to prompt Claude. And eventually we might not even need loops, right? We’re just gonna have like swarms of agents designing loops to prompt agents building swarms for loops, and like, I don’t know, somewhere we’re like writing production code, I assume. And in fact, all of our loops that we’re building are producing…

Kyle Mistele: 3:00 So much code that we can’t possibly read all of this, right? So we might as well just not read any of it, right? We’re we’re investing in verification and in code review, but all this code is read-only. This is the the thesis of a conference that was here in town last month. So a lot of smart people at the frontier labs think that this is the future of software development and if you’re doing this, you’re moving 10x faster and everybody else is getting left behind. Now, it’s not clear how well this works yet.

Kyle Mistele: 3:30 It took six months to fix the Claude code terminal flicker. The Open Code team wrote a renderer in a fraction of that time. And Open Claude, of course, also notoriously has stability issues.

Kyle Mistele: 3:41 What is abundantly clear, however, is that this shit is really expensive if you don’t work at a frontier lab and have an unlimited token budget. And all this code that we’re writing is actually really expensive, right? Matt Pocock talked about this recently. Bad code is much more expensive in the age of agents than it has ever been at any point in the past. So today, I want to talk about what I think works in the real world and what we’ve started doing it here at Human Layer.

Kyle Mistele: 4:06 Which, to be clear, is still building loops, right? I think loops are super powerful, but we can design loops and still read the code. In fact, we can design loops that make it easier to read the code because the loops are making the code better. We can solve hard problems in complex code bases with loops and we can build our software factory incrementally. But uh

Kyle Mistele: 4:31 To do this is going to take some real engineering, y’all. So let’s talk about control theory.

Kyle Mistele: 4:41 Control theory is all about how we drive a dynamic system, which would be your codebase, towards some desired, stable, or optimal end state, right? You have a sensor that measures the current state of the world. You have your set point, right? The desired state of the world, and the difference between those two things is your measured error. You have a controller that reads that measured error and turns it into a control signal about an incremental change

Kyle Mistele: 5:02 to apply to the system. We have an actuator that applies that change to the system, which is undergoing disturbances in the meantime. And then we remeasure, recompute our measured error, and we’re back where we started. Now, this sounds really complicated, and it can be. I have a twin brother, actually, who’s an aerospace engineer. This is how they keep fighter jets from falling out of the sky.

Kyle Mistele: 5:22 But uh, it’s probably a little bit simpler than most y’all think. Does anyone have one of these?

Kyle Mistele: 5:37 A thermostat uses a control loop, right? For for any of our European friends in the audience, this is part of something we have here in the states. It’s called air conditioning. And uh, most of us probably actually use control loops on a daily basis, right? Kubernetes autoscaling systems are built on control loops. Infrastructure as code uses a desired state, current state, iterative change-like control loop pattern. Postgres’s auto-vacuum

Kyle Mistele: 6:00 React’s virtual DOM, both use approximate control loops.

Kyle Mistele: 6:04 Control loops are ideal when we have a system that we want to change, a problem we can measure, and a way to get feedback on the results of that change.

Kyle Mistele: 6:11 Like good software engineers have always been taught to do, control loops change a system incrementally instead of just trying to get straight to the end state immediately all at once and risk blowing everything up, right? They help us to avoid oversteering and destabilizing the system, and it minimizes risk.

Kyle Mistele: 6:30 So control loops are the opposite of what I’m going to call our blind Ralph loop. They’re how we avoid PRs that look like this, because nobody wants to review this, right?

Kyle Mistele: 6:39 Which is not to say that all Ralph loops are blind loops. The best Ralphs are actually applying control theory. I know Jeff Huntley is out in the hall somewhere wandering around. If you go talk to him, he’s going to tell you the same thing, right? That Ralph is a- a teaching device, and I think some of us read it a little too literally, but this is how we should have always been building loops.

Kyle Mistele: 7:00 But the other issue with Ralph loops, they’re not incremental, right? It’s just a bash loop.

Kyle Mistele: 7:05 So we have to build agentic control loops. And to do that, we start by defining a set point, which is the desired end state of our code base with respect to some property of it. And we add a sensor. There’s a lot of ways to build a sensor. It can be strictly deterministic. Your ESLint rules, your AST-Grep, your Packwork, or it can be non-deterministic. You can have an agent and a skill and a bunch of natural language rules, and you could also just have a pipeline, like a combination of the two.

Kyle Mistele: 7:21 So how do we build agentic- whoops.

Kyle Mistele: 7:26 There we go. Now, uh, this is all theory, right? Practically speaking, and because we’re using agents, we can blur the lines a little bit between system components.

Kyle Mistele: 7:36 Aiden by React Doctor, for example, is fantastic. It is- uh, it’s a great way to catch all of the React slop that Claude snuck into your code base last week. But uh, it’s a hybrid sensor and controller. It tells you what are all the problems with your React code and also by the way, what are the top three things you should fix and how do you fix them?

Kyle Mistele: 7:53 Similarly, our controller and actuator might actually just be a single agent deciding on an incremental change to make and then applying it in the same context window.

Kyle Mistele: 8:05 But I want to zoom in on the controller a little bit because without one, or without a well-tuned one, we might make too large of a change all at once, or we might make the wrong change entirely. And if you put that in a loop, you’re in trouble pretty quickly.

Kyle Mistele: 8:16 So we can use control loops to root out bad patterns and to clean up our code, but we can actually use them for all sorts of things, right? We could make sure that our API is compliant with someone else’s OpenAPI spec. We can make sure that our MCP server is compliant with whatever version of the uh, the MCP specification that we’re currently on. Haven’t checked. You could mirror a project from Python into TypeScript, or vice versa. You could even maintain your uh, V-based Slop fork of Next.js against the upstream.

Kyle Mistele: 9:00 The key questions are can we find something we can measure, can we apply changes incrementally, and can we get feedback on the quality of those changes.

Kyle Mistele: 9:08 To illustrate that, I’m going to walk through a control loop that we use internally at human layer.

Kyle Mistele: 9:13 For our loop, we are incrementally migrating our RPC API to effect.

Kyle Mistele: 9:18 We adopted it for some of our race-prone code, we like it, so we’re adopting it across the rest of our codebase.

Kyle Mistele: 9:23 If you’ve never seen effect code before, the code on the right is just the kind of trivial procedure on the left rewritten in effect.

Kyle Mistele: 9:30 The syntax is really weird, we’re psychos, we really like it, it’s not for everybody, that’s okay. This isn’t a talk about effect, so we’ll keep moving.

Kyle Mistele: 9:41 Step one, we have to build our sensor to find unmigrated procedures.

Kyle Mistele: 9:45 We could have an agent do this, or we could use grep or ripgrep.

Kyle Mistele: 9:51 But instead we’re going to use AST-grep because it’s really powerful, it’s a great tool to have in your toolbox for building loops, it’s language agnostic, it’s out-of-band from your typescript config or ESLint rules, which if you’re a typescript developer you have watched Claude disable those with inline comments.

Kyle Mistele: 10:06 But so we can just write a simple rule that finds unmigrated procedures based on the pattern above.

Kyle Mistele: 10:10 And over time we can even layer on more rules that describe other patterns we want to get rid of with granular include and exclude paths.

Kyle Mistele: 10:17 If you have a multilingual monorepo like we do, it’ll work for any language you could possibly imagine. And we can just scan our codebase and it’ll produce a long list of violations.

Kyle Mistele: 10:25 Way too long in fact, it’ll give you about 50 keys per violation, so we’re just going to filter it down to four and we’re going to sort it deterministically. Why are we doing that?

Kyle Mistele: 10:34 At the beginning I said this was going to be practical and so we’re going to step outside of our control loop paradigm for a second because before we start incrementally migrating procedures one at a time, we need to enforce that all new procedures are using effect, right?

Kyle Mistele: 10:47 So we’re going to run a full scan once on main, sort all the violations deterministically, and track it in our version control.

Kyle Mistele: 10:54 And then on every new PR, we can see if the branch added any unmigrated procedures, right?

Kyle Mistele: 11:00 So this is our control loop and our system is undergoing disturbances, in this case all of our teammates shipping Claude’s slop, and this is how we make sure that they’re not undoing our loop’s work.

Kyle Mistele: 11:11 This doesn’t map directly to a part of the control loop, but we can kind of like squint at it a little bit and call it a disturbance dampener.

Kyle Mistele: 11:19 So now that we’ve stopped the bleeding, we can actually design our controller.

Kyle Mistele: 11:22 For a simple controller, we could just deterministically pick the first violation from the list. You can use bash and jq, or we could get a little cleverer and use AST-grep to find the smallest unmigrated procedure and always pick the smallest one to reduce the risk.

Kyle Mistele: 11:37 We could have an agent make the decision if we really want to. I don’t think you should ever send an agent to do deterministic code’s job, but you certainly can.

Kyle Mistele: 11:45 In fact, depending on the complexity, we could have the agent pick the procedure to migrate and just do it at the same time, like we just talked about.

Kyle Mistele: 11:52 But we can make this even more powerful, right? Because we’re not just migrating to effect for the sake of it, we’re doing it because it’s helpful for handling errors and for helping us instrument.

Kyle Mistele: 12:00 We want our code better and so what we could do if we want to get really clever is we can look at our telemetry and figure out which procedures have the most errors or the least instrumentation or has a gap in our ATM, right? And when we send a control signal to our actuator agent, we can include not just the procedure to migrate, but also all the data about the things that we’re trying to fix with this migration so that the actuator agent can actually make the code better instead of just doing a one-to-one migration.

Kyle Mistele: 12:30 Oh man, there we go. So next is building our actuator. Our actuator is just an agent plus a skill. Um bring your CLI coding agent of choice. You should spend a lot of time on the skill, not all of that should be up front. You’ll want to iterate on it over time based on what works. At Human Layer, we like to build out what we call golden patterns by hand before setting the agent loose. These are just like idiomatic handwritten examples for the agent to follow because they’re just pattern replicators and otherwise you’re getting what’s in the docs or what the agent knows from the internet. And so we pipe the skill plus our control signal into our actuator agent. And the skill of course should include a response template. And the agent’s going to work and work and work and it’ll produce a final response. And then we’re going to deterministically commit and push and create a PR using the final message as our PR description.

Kyle Mistele: 13:23 Now all we have to do is actually run the loop, right? Uh my recommendation is to use GitHub Actions or your GitLab or your CircleCI or whatever else you’re using because it has access to your code, it has access to your secrets and it has great dispatch and scheduling primitives, right? We don’t need a new cluster for this. So we can write a workflow that runs a single iteration of the loop, sense control, actuate, and creates a PR. And then we can schedule this to run once a day. And every morning, we walk into the office to a small incremental PR that’s low risk.

Kyle Mistele: 13:54 And when we first did this, it was actually really frustrating and we turned the loop off and it uh because we had to constantly update the skill, we had to constantly check out the branch, change the skill, change the code, commit and push and our loop was actually really high friction, right? But there’s a better way to do this uh where we can put a human on the loop and a really low friction way to resteer it when it goes wrong. And the way to do this is to just create a feedback file that’s tracked in version control just as a markdown file, right? We can deterministically load it into our actuator agent’s context every time that it runs after we run the controller. Then we can add a label to the PR, right? Each workflow needs to be able to identify PRs that it created since there might be a bunch of different loops running and we only want workflows to respond to feedback from uh comments on their PRs. And we’re going to add a comment trigger to each loop workflow. So when a user leaves a slash iterate comment on the PR, uh the loop workflow is going to pick that up, it’s going to deterministically load all of the PR context, the diff, the comments, the review comments, the description into the agent’s context along with the skill and it’s going to instruct the agent to fix the code, but also to update that feedback file, right? It looks kind of like this:

Kyle Mistele: 15:00 And the benefit of doing this way is that now that feedback file with instructions is tracked in your version control, you can see how you’ve changed it over time, you can revert it if you need to.

Kyle Mistele: 15:10 So the next thing we’re going to do is add flow control, because the other problem that we had when we did this was that if we were at a customer site for a week, or if we were traveling, or spent six days working on slides instead of writing code, the PRs from all of our loops would just stack up, they’d duplicate work, they’d conflict,

Kyle Mistele: 15:30 and we wouldn’t get around to doing it, and like the loop’s work is important, but it’s not that important, and so now we just had all this like junk we had to deal with that wasn’t important.

Kyle Mistele: 15:40 So, this is actually a really easy problem to fix, uh, because each loop and its workflow has a label that gets attached to PRs. When the workflow first runs, uh, before we check out the code and install the dependencies and run our sense actuate- or sense control actuate steps, we can just check and see if the last PR that we created or any PR with the loop’s label on it is open. And if so, we just shut it down, right, because this means that the last time that a human, uh, reviewed the code from this loop was before the loop ran, right? No human reviewed the last output, so there’s no reason to stack up even more work for humans to review.

Kyle Mistele: 16:15 This way we have exactly one PR at most open per loop at a time, no stacking, no duplication, hopefully no conflicts. And of course, once you’re feeling confident in the loop, we’re going to want to speed it up, right?

Kyle Mistele: 16:25 I have 150 RPC procedures to migrate. If I do one at a time it’s going to take six months, which is way longer than I want to wait. Fortunately, there’s a lot of ways to pick up the velocity of our loop. Uh, we could have our controller pick three procedures to migrate instead of one at a time, or five.

Kyle Mistele: 16:41 Uh, we could have our controller pick three or five and then do each of those in a separate implementation phase, which will be both cheaper and more reliable since each migration gets its own context window. Or we could just run the workflow four times and give one PR to each of four people on the team.

Kyle Mistele: 16:56 So, let’s put it all together. We built a control loop that improves our code incrementally, and we’re actually reading the code. It has adaptive flow control so we’re not creating a bunch of loop- or a bunch of work that nobody wants to review. And we can re-steer it on the fly in a super low-friction way.

Kyle Mistele: 17:12 If you want to try this yourself, uh, we built a skill. Please try it out. My Twitter handle is down there on the bottom. Please share it. I would love to see what you build.

Kyle Mistele: 17:24 And if you get excited by this, uh, at Human Layer we’re hiring here in San Francisco. And if you’re working on mission-critical systems and want to figure out how to get more out of AI, we’d love to chat. Thank you so much.