How to Make AI Agents Improve Themselves: Build the Loop, Not the Changes ​

A glowing teal loop track with measurement gates: most agent cores are rejected down chutes into a dim pit, and one core leaves the loop on an exit track glowing coral

At Komodor we build agents that investigate production incidents. A lot of our work this year went into one question: how do you make an agent improve itself, without a person reading every run and rewriting the prompt?

Writing a new version of an agent is cheap now. A prompt edit, a new skill, a cheaper model, a coding agent opening the PR. Knowing whether that version is better at the job is the expensive part. A self-improving agent is a loop that answers that question on its own, round after round, and keeps only the changes that prove themselves.

The idea is in the air. Software factories (Dan Shapiro's five levels, StrongDM's team that doesn't review its own code) turn specs into code and validate it against hold-out scenarios. Three days ago OpenAI described a Performance Factory where Codex agents root-cause ChatGPT latency regressions and propose the fixes. Both use agents to improve software. This post points the same machinery at the agent itself.

The loop ​

Animated loop: production runs, grade, datasets, coach, candidate, replay, shadow, promote. Three candidates go around; two land inside the noise band at replay and drop into reverted, the third beats the noise and is promoted

  1. Run. Record every run: the input, the tool calls, the answer, tokens and time.
  2. Grade. An evaluator scores every run against the outcome, with a written reason. People grade too, without extra work: when an engineer approves, edits or rejects the agent's conclusion, that is a label, and the edited answer is ground truth.
  3. Collect. Graded runs become versioned datasets. Recordings keep the original tool results, so a replay touches nothing real. Public benchmarks sit next to them as an outside yardstick.
  4. Propose. A coach agent reads the failures and the grader's reasons and proposes one change: a prompt edit, a skill, a narrower tool scope, a different model. It never sees the answer key. A coding agent can drive the same step from outside.
  5. Prove. The change becomes a new revision, never an edit to the running agent. It replays on the dataset several times against a baseline whose noise was measured before the experiment started. It is kept only if the gain clears the noise and no other metric breaks its limit.
  6. Shadow. The kept revision runs beside production on live traffic. The caller only hears production. A blinded judge grades both answers.
  7. Promote. The winner becomes production, optionally through a sticky live split first. Promotion is a recorded revision, and the previous version stays as the fallback.

The new production runs feed step 1, and the next round starts.

A loop we ran: making an RCA agent faster ​

This one is from our own agents, not a toy. The student ran on a cheaper model, a coach agent on Opus proposed the changes, and a separate model applied them.

The agent investigates Kubernetes incidents, and the benchmark was Cloud-OpsBench. The objective was speed: mean seconds per investigation, with two limits written down before the first run - accuracy must not drop beyond its noise, cost must not rise beyond its noise. The student was Haiku 4.5. The cases were split into train, validation and a test tier nobody looked at until the end.

The coach read the baseline's transcripts and described the student like a coach describes an athlete: it runs in two speeds, and the slow runs are mostly the wrong ones; once it is lost it keeps investigating instead of stopping; it speculates past a cause it already found; it writes long shell loops that hit the two-minute tool timeout.

The first coach ran four rounds. One was kept (-39% time on train, -46% on validation, cost -43%), three were reverted, and the loop stopped itself because two rounds in a row landed inside the noise band. A second coach, started from a baseline re-run under the production request shape, kept one round of three. Then the test tier, read once:

Test tier (5 cases, 2 runs each)BaselineChampion
Mean time per investigation103 s64 s (-38%)
Cost per run$0.286$0.154 (-46%)
Tool calls30.722.3
Correct runs7/107/10

Same accuracy, a bit more than a third faster, a bit less than half the cost. Five test cases is small, and the speed is measured on recorded tool results, so it counts model turns and tool calls, not real cluster latency.

If you want to watch the whole cycle on your laptop, the smallest version is public: komodorio/hello-world-continual-learning, a teacher, a student, a grader and a coach on four support tickets.

The human builds the loop, not the changes ​

Animated: four agents each circle their own improvement loop; cost-agent stops and raises a coral flag because two metrics trade, while rca-agent, triage-agent and review-agent keep running

In a software factory the engineer stops writing code and starts writing specs. In a self-improving loop the engineer stops approving changes and starts building the validation: the answer keys, the noise band, the hold-out, the limits on cost and time. That is the real work.

Once the validation is consistent, the loop can run fully automatic, from proposal to promotion. Gain above the noise band on a hold-out it never trained on, every other metric inside its limit: promote. Otherwise revert and try the next change.

A good loop also knows when it needs help, and asks for exactly that while everything else keeps running:

The loop raises a hand whenWhy it can't decide alone
Two metrics trade: more accurate, but more expensive per runThe trade is a business call
The model judge disagrees with human labels on the same runsThe grader is no longer trusted
A gain on training cases does not show on the hold-outIt is probably overfitting the answer key
Rounds keep landing inside the noise bandIt needs more data or a different objective
Live traffic has no answer key, only a model judgeNothing ground-truth to promote against
The budget is spentSomeone agreed to a number

One flagged agent waits for an answer. The others keep improving. The human sets the objective, the limits and the budget once, reads the changelog, and answers the flags.

What works, and how to do it ​

This is what we think makes an autonomous self-improvement factory work. Each point comes with how to do it, and with evidence from other teams building the same kind of factory, not only ours.

  1. Grade the outcome, item by item. Write the outcome in one sentence a domain expert would sign, turn it into a checklist, and score each item separately. Averaging a correct decision with a friendly tone lets a wrong answer pass. Anthropic's guide to agent evals makes the same call: grade what the agent produced, not the path it took.
  2. Start from real runs and real failures. Record traces, and treat every approval, edit or rejection by a person as a label. Every failure becomes a permanent regression case. Anthropic suggests starting with 20-50 tasks taken from real failures. LangChain puts it as "in AI, the traces" document the app. OpenAI's Performance Factory evaluates its agents with backtests against past incidents.
  3. Measure the noise before you improve anything. Run the baseline more than once on the same cases, and keep a change only if its gain clears that spread. Agents are less repeatable than they look: by Anthropic's arithmetic, an agent that succeeds 75% of the time on a task succeeds on all three of three tries only about 42% of the time. In our speed run, two rounds of seven cleared the band.
  4. Hold out what the improver never sees. Keep a test tier outside the loop and read it once, at the end. StrongDM keeps its scenarios outside the codebase, like a hold-out set, so agents cannot pass by writing tests that assert true. Our speed result above is the test tier, read once.
  5. The one who proposes never grades, and someone tries to disprove it. Split the coach from the judge, and add an adversary. Google's agent quality flywheel never lets the optimizer grade its own fix. OpenAI runs a separate Codex session whose job is to disprove each diagnosis.
  6. Check the grader against people. A model judge drifts, and its partial-credit reasons can leak the answer to whatever is learning from them. Compare it with human verdicts on a sample, and trust deltas more than absolute scores. When OpenAI hand-graded 100 of its agents' root causes, 70% were accurate.
  7. Score the agent the way the world will. If a benchmark counts a timeout as a failure, so do you. We dropped timeouts as "infra" once and our numbers looked better than they were. And score the agent, not a proxy: we watched validation loss improve while the agent got worse.
  8. Change one thing, as a version in git. The agent's prompt, skills, tools and model live in version control, and every change is a new revision you can diff, replay, shadow and roll back. Warp lists configuration kept outside git as a reason self-improvement loops fail: there is nothing to diff.
  9. Shadow before live, with side effects off. A shadow agent must not restart a pod or post to Slack twice. StrongDM goes further and tests against agent-built behavioral clones of Okta, Jira and Slack.
  10. Write down where a human is needed, and automate the rest. OpenAI's workflow configuration lists which steps need an engineer. A loop with scorers but no improver is, in Warp's words, a dashboard. Spend human time on the validation, then let go.

The hard part ​

Animated: seven coaching rounds drop onto a chart with a gray noise band measured before round 1; rounds 2 and 5 land above it and are kept, the other five land inside it and are reverted

Most of the loop produces nothing. In our speed run, two rounds of seven were kept. The rest were correctly thrown away, and still paid for. OpenAI found the same shape on its side: agents were better at finding root causes than at fixing them, and their fixes were sometimes more complicated than necessary.

Replay needs recorded tool results, and an agent that does something new mid-investigation runs off the end of the recording. The grader is a model, so compare it with human verdicts before trusting its numbers. A blind judge hides the author; it does not make the judgment right.

A fully automatic loop on a benchmark will overfit that benchmark. When we trained a model on its own corrected sessions, the gain sat on the cases it trained on, and the rest barely moved. The hold-out is the only thing standing between "automatic" and "automatically wrong".

What is the outcome your agents are hired for, and how many of last week's changes to them could you prove made it better?