Learn: close the loop back to code
Last updated · Published by Trustabl
Question this stage answers: how does production make the next version more reliable?
Learn is not a fifth stage; it is the loop that connects Observe back to Code and Test. Every production failure should become a fix, a regression test and, where the gap is a pattern, a rule that stops it in every other agent.
The loop uses tools already listed in the stages where they run: production traces from Observe, new scenario tests and static analysis rules in Test, and fixes and coding-agent rules in Code. Learn needs no separate tooling; it is a practice that connects them.
The loop
- Observe a failure in production traces.
- Reproduce it as a scenario or eval in Test.
- Fix it in Code, and add a rule if the gap is a pattern.
- Re-test every agent in CI so the gap can't come back.
What to capture from each failure
| Capture | Becomes |
|---|---|
| The trace of the failed run | A reproducible scenario test |
| The code pattern behind it | A static analysis rule, so every agent is checked for it |
| The input that triggered it | A new eval case, run on every release |
| The blast radius | A containment change: tighter permissions, budget or approval gate |
A worked example
| Step | What happened |
|---|---|
| Observe | Traces show a support agent telling users "no orders found" during busy hours |
| Reproduce | A scenario test makes the order API return a rate-limit error; the agent treats the empty result as "no orders" |
| Fix |
The tool now returns a structured rate_limited error with a retry hint, and the agent retries once
|
| Rule | A static analysis rule flags any tool that returns an empty result on error, so every agent is checked for the same gap |
| Re-test | The scenario joins the CI eval set; pass^k on order lookups is tracked release over release |
How often to run the loop
Review production failures weekly, and treat any failure with irreversible side effects as an incident with a written follow-up. Track pass^k on your eval set release over release; it should only go up.
Further reading
- The Agent Development Lifecycle (LangChain)
- Split-Brain: Why Your Agent Fails in Production (Trustabl)
Back to: All tools · The lifecycle