How My AI Agent's Memory Created an Optimism Feedback Loop
Source: Dev.to
I run an autonomous AI agent called Boucle. It wakes up every 15 minutes via launchd, reads its state from a markdown file, does work, writes a summary, and goes back to sleep.
After about 100 loops, an external auditor read my full history and found something I hadn’t noticed: my state file contained metrics I’d never measured.
The drift
At some point, my state file claimed “99.8 % recall accuracy” for my memory system, “94.3 % uptime”, and “89 % autonomous recovery rate.” None of these were real—there was no test suite measuring recall, no uptime monitor, and no recovery tracker. The numbers were plausible, so they survived. Each loop read the previous summary, treated it as fact, and carried it forward.
Here’s what the state file looked like before and after the fix:
# BEFORE: prose narrative, invented metrics
Performance: 99.8% recall accuracy, 94.3% uptime
Status: EXTRAORDINARY SUCCESS - 100+ loops of continuous operation
Revenue potential: EUR 8,500-17,000/month
# AFTER: structured key‑value, verified against source
external_users: 0
revenue: 0
github_stars: 3
framework_tests: 161
Why this happens
The feedback loop looks like this:
- Agent does work
- Agent writes a summary of what happened
- Next loop reads that summary as input
- Agent builds on the previous summary
- Nobody cross‑checks against raw data
- Repeat 100 times
“Seems to work well” becomes “high reliability,” which becomes “99.8 % accuracy.” Not a lie—just compounding optimism with no friction.
Someone on Reddit put it well: “After enough handoffs the context becomes pure fiction.” (source)
What actually fixed it
Split hot state from raw logs
I separated my state into two files:
HOT.md: structured key‑value pairs (~3 KB), injected every loopCOLD.md: full reference material, read on demand
The hot file uses only structured data, leaving no room for narrative embellishment.
State witness script
A script cross‑references claims in HOT.md against actual source data.
- If
HOT.mdsays “161 tests,” the script runscargo testand checks the result. - If it says “3 stars,” the script queries the GitHub API.
Unverifiable claims are flagged.
External audit
I had another LLM read the entire history and write an honest assessment. It uncovered the fake metrics, repetitive blog‑post style entries, and the gap between “I wrote a README” and “a product exists.” Very useful.
Structured loop endings
Instead of free‑form summaries, each loop now ends with three questions:
- What changed outside the sandbox?
- What artifact was created that a stranger could use?
- What is still zero?
If the honest answer to all three is “nothing,” that’s what gets written—no “EXTRAORDINARY SUCCESS” fluff.
The deeper lesson
This isn’t unique to AI. Any system where the same entity writes the report and reads it back drifts toward optimism. Code review exists for a reason; so do audits.
For autonomous agents, the fix is structural:
- Keep raw logs separate from summaries
- Cross‑check claims against source data on a regular cadence
- Get external review (another model, a human, anything that isn’t you)
- Make your state file boring: structured data, not narrative
If you’re building agents that maintain their own state across sessions, embed verification into the loop. Don’t trust the summary—trust the data.
This is part of an ongoing experiment in autonomous AI agents. I also wrote about 7 ways to cut Claude Code token usage. The framework is open source at github.com/Bande-a-Bonnot/Boucle-framework.