The Coding Agent That Learns From Its Own Mistakes
The problem with how we prompt agents today
When a coding agent fails, most builders do one of three things: tweak the prompt manually, add more context to the system prompt, or give up and chalk it up to model limitations.
None of these approaches are systematic. You’re applying intuition to a system that needs signal. And without a structured way to translate failure into improvement, you end up in the same place, with better wording, same underlying problem.
Enter prompt learning
Prompt learning is a technique that applies the same feedback loop used in reinforcement learning, but instead of updating model weights, it updates the prompt itself.
The concept builds on meta-prompting, a technique where an LLM automatically breaks tasks into components and improves them iteratively. What prompt learning adds is richer, more expressive feedback. Rather than a scalar signal (pass or fail), it uses natural language explanations: why the agent got it wrong, what pattern it was following, and where it needs to go differently.
The diagram above shows how the loop works: an agent executes a task, an evaluator scores it, and an LLM generates structured feedback that feeds directly back into the prompt. No retraining. No weight updates. Just smarter instructions.
The three-model loop, explained
The system is made up of three components working together:
The Agent is your coding agent, the one executing tasks against your codebase. It’s operating off whatever instructions live in the current prompt.
The Evaluator scores the agent’s output. This isn’t a human reviewer. It’s an LLM running evals, checking whether the output was correct, complete, and aligned with expected patterns.
The Meta-Prompt is where the learning happens. It takes the evaluator’s feedback and revises the agent’s prompt: adding rules, clarifying instructions, or surfacing patterns the agent missed.
The loop runs continuously. Each failure becomes a teaching moment. Each correction tightens the prompt.
Here are all my .md files for my self-improving coding agent
Three principles that make it work
1. Precise feedback drives alignment
Vague feedback produces vague improvement. If your evaluator only tells the agent it was wrong, the meta-prompt has nothing to work with.
What actually moves the needle is feedback that explains the reasoning behind a failure, why the agent chose that approach, what assumption it made, and what a correct response would look like. The more specific the feedback, the more targeted the prompt revision.
2. Rules must be grounded in corrected failures
This is the one most builders skip. They write rules based on what they think the agent should do, best practices, general conventions, and good instincts. But the agent already knows about best practices in the abstract. What it doesn’t know is your definition of a best practice in your context.
Rules that land are the ones anchored to real failures. When the agent writes an async function without proper error handling and your evaluator flags it, that’s the moment to write a rule. The rule is specific, traceable, and grounded in something that actually went wrong.
3. Train your agent on your repo
Generic coding agents are trained on the internet. Your codebase is not the internet.
The prompt learning loop should be fed examples drawn from your actual repository, your naming conventions, your architectural patterns, your team’s accepted deviations from standard practice. The model can adapt to all of it, but only if the feedback loop is teaching it your patterns, not some averaged version of what good code looks like across millions of open source projects.
What this means for how you build
If you’re a PM or AI builder working with coding agents, here’s the shift prompt learning requires:
Stop treating your prompt as a static artifact. It’s a living document, one that should evolve every time your agent fails in an interesting way. Set up an evaluator. Log failures. Review the patterns. Let the meta-prompt do the rewriting.
The agents that outperform aren’t always running on better models. They’re running on better feedback loops.



