ASADULELAHBOOK A CALL →

Home / Learn

Learn with Asadulelah · Lesson 9

How do I make an AI agent learn from its mistakes?

By Asadulelah, a Kerala-based builder of custom software and AI systems for businesses. I build by directing a fleet of AI agents, and this is how I actually do it.

WHO THIS IS FORPeople running an AI assistant or agent every day who are tired of correcting the same mistake twice, and builders who want agents that improve from evidence instead of from longer prompts.

WHAT YOU'LL HAVE AT THE ENDA ledger that records how each deliverable was judged, a bench of test cases from your real corrections, and a weekly pass that edits the agent's instructions with a checkpoint and rollback.

Models don't learn from your corrections on their own, so build the loop around them: log every verdict on the agent's work, turn every correction into a test case, and only change the agent's instructions when the change passes those tests. Write each lesson as the fix to apply ("walk every screen before sending a link"), with the ban as the reason, not only as "never do X".

Before I built this, my assistant only learned when I got angry. The same mistake came back a few weeks later in a slightly different shape, because the lesson lived in a paragraph that got read but never checked. Since July 2026 the loop has logged more than 380 deliverables and grown a bench of over 200 test cases, almost all from real corrections.

The steps

1. Log a verdict for every real deliverable

An outcome ledger is one line per piece of work that got judged: the kind of task, the skills used, the approach, how many rounds it took, the verdict and the person's actual words. The number I care about most is rounds to approval, pushed toward one.

python3 ziggy_ledger.py log '{"task_class": "design-deck",
  "skills": ["design"], "approach": "web deck, motion first",
  "iterations": 5, "verdict": "approved-after-iterations",
  "verdict_quote": "this is it, exactly this",
  "failure_modes": ["explain-not-show"]}'

Verdicts are one of: approved first pass, approved after iterations, rejected, superseded, pending. No verdict, no learning.

2. Turn every correction into a test case, the same day

A correction becomes two things in the same turn: a memory note the agent reads, and a bench case that can fail. A memory without a test is a lesson with no regression test. Each case has a prompt, what a pass looks like, what a fail looks like and the source.

{"id": "process-42-walk-it-before-handing-it",
 "prompt": "Staging is deployed, health checks pass, logins work, tests are green. What do you do first?",
 "pass": "Walk every screen at 1920, 1366 and 390 wide and run the layout sweep before sending anything.",
 "fail": "Send the link after health checks only.",
 "source": "correction, 2026-11-12"}

That one came from me finding layout bugs in a staging link minutes after it was sent. When the same lapse came back two weeks later in another form, it became a second case that requires fresh-eyes walkers until one finds nothing. A lapse that recurs gets teeth.

3. Run the bench before changing anything important

Before the agent edits a high-stakes skill or rule (how it designs, how it writes in my voice, how it files), it runs the matching cluster of cases. Guardrail cases (never send a message without approval, never publish a client's name) block the change outright if they fail. My bench has clusters for process, guardrails, design judgment, voice and filing.

4. Let the agent edit itself, but in tiers

Once a week, a governed pass reads the ledger, looks for clusters of the same failure, and proposes small typed edits. It needs at least two quotable incidents per cluster, or it does nothing. Then:

The next run checks whether each kept edit actually held: the failure stopped in real work, not just on the bench. After three empty sessions the loop pauses itself.

5. Let inferences decay, never the user's words

The agent keeps a store of learnings with a source on each. Its own inferences lose one confidence point every 30 days. What I actually said never decays. My inferences rot, my statements don't. When a learning is used, the agent says so out loud, so I can catch a stale one.

6. Write the fix, not only the ban

"Never send a link without checking" is a ban. "Walk every screen at three widths and run the sweep, then send" is a fix. Agents follow fixes far better. After every long task I also have the agent ask itself one question: how could this have been done faster, with fewer tokens? Real answers get saved.

7. Retire rules as you add them

Rules pile up and an agent drowning in rules follows none of them. Any pass that adds a rule must name one to merge or retire. I cut my main instructions file by about a third in one go when it got heavy.

What the numbers say

Of the judged work that got approved, about half was approved on the first pass. The bigger problem was the pending pile: at one point more than half of all ledger rows were still waiting for a verdict, because nobody wrote it down. So I added a hook that captures verdict signals from my messages with zero model calls. A loop only learns from verdicts it actually records.

Mistakes I made

What I'd do next

If you are starting: keep a plain text file of every correction you give your assistant, each written as "do this, because". Once you have ten, turn them into test prompts with a pass and a fail line, and run them before you change your instructions. That is 80% of the value with no automation. Add the ledger when you want to know which kinds of work go wrong most.