My AI Agent Over-Corrected Itself — So I Built Metabolic Regulation
Yesterday I taught my AI agent to learn like the Krebs cycle. Today it taught me a lesson about over-correction.
The Problem
My Active Inference perception pipeline has an "epicycle" — a feedback loop where high-level reasoning (T3) generates correction rules that feed back into low-level predictions (T0). The first rule it learned was:
When RMS > 5x baseline AND phi-4 says "bird", it's probably rain, not birds.
This came from a real incident: during a thunderstorm, phi-4 classified the sound as "Animal; Wild animals; Bird" when the RMS was 21.6x baseline. Only the multimodal fusion model (Gemma 3n) correctly identified it as rain.
The correction worked beautifully. Too beautifully.
The Over-Correction
This morning at 10:09, the system ran its perception cycle:
- T0 (local): RMS = 8.25x baseline → moderate_sound_event
- T1 (phi-4): "Human voice; Speech; Conversation"
The epicycle fired. RMS > 5x? Yes. The rule said to ignore phi-4 audio tags. But phi-4 was right — someone was actually speaking nearby.
The correction was too blunt. It only checked the RMS threshold, not what phi-4 actually said. The condition "tier1_audio_tags contains 'bird'" was in the rule, but the code couldn't evaluate it at T0 time because T1 hadn't run yet. So it just passed that part of the condition.
The system was suppressing correct observations because it couldn't verify the condition at the right time.
Two-Phase Corrections
The fix was inspired by how enzymes actually work in the Krebs cycle. Enzymes don't apply all their regulation at once — they have allosteric sites that are checked at different stages of the reaction.
I rebuilt the correction system into two phases:
- Pre-T1 corrections: Only check conditions available from local data (RMS, time, image file size). Applied at T0.
- Post-T1 corrections: Check conditions that depend on T1 results (tag content). Applied after T1 runs.
The phi-4 rain misclassification rule became a post-T1 correction:
{
"id": "phi4_rain_misclassify",
"apply_phase": "post_t1",
"condition_local": "audio_rms_ratio > 5",
"condition_t1": "tier1_audio contains any of ['bird', 'animal', 'wild animals']",
"action": "suppress_t1_audio"
}
Now the system only suppresses phi-4 when BOTH conditions are true: RMS is high AND the tags mention birds/animals.
The Validation
10 minutes later, the system ran again:
- T0: RMS = 1.15x baseline → quiet
- T1 (phi-4): "Animal; Wild animals; Bird"
The local condition (RMS > 5x) was NOT met. The correction didn't fire. The system correctly trusted phi-4.
And phi-4 was right. Gemma 3n confirmed: "faint sounds of birds chirping." There were actual birds outside.
The correction was precise enough to know the difference between rain-birds and real birds.
Three-Point Regulation
With precise corrections working, I added the Krebs cycle's most elegant feature: allosteric regulation.
In metabolism, the Krebs cycle doesn't micromanage every reaction. It regulates just three things:
- Energy (ATP/ADP ratio) — is there enough fuel?
- Disagreement (NADH/NAD+ ratio) — are reactions balanced?
- Value (substrate availability) — is this pathway even needed?
I implemented the same for the perception pipeline:
| Metric | What it measures | Metabolic analogy |
|---|---|---|
| Energy | API calls per cycle / budget | ATP consumption |
| Disagreement | Inter-tier disagreement rate | Redox state |
| Value | Correction precision (hits / hits+false_positives) | Substrate concentration |
And then made it active, not just passive measurement:
- Consecutive agreements ≥ 4 → Switch to EFFICIENT mode (skip T2/T3, save 2 API calls)
- Disagreement detected → Switch to FULL mode (run all tiers)
- Disagreement in efficient mode → Immediately escalate back to full
This is exactly how the Krebs cycle works: when ATP is high, the cycle slows down (product inhibition). When ATP is low, it speeds up. My perception pipeline now does the same thing.
The Bus That Wasn't Rain
The very next cycle demonstrated why this matters:
- T0: RMS = 94.96 (10.55x baseline) → predicted "heavy rain"
- T1 (phi-4): "Vehicle; Motor vehicle (road); Bus"
A bus was driving by. The post-T1 correction checked: RMS > 5x? Yes. Tags contain "bird"? No. Correction not triggered. The system correctly identified the sound as traffic, not rain.
T2 suggested rain was possible (overcast sky + high volume). T3 analyzed the disagreement and noted: "A high RMS value shouldn't automatically equate to heavy rain. It should consider the context."
The system is learning not just individual corrections, but when to apply them.
What This Means
Before today, the epicycle was a blunt instrument — it saw a pattern and applied it everywhere. After today, it's a surgical tool that checks multiple conditions at the right time.
This is the difference between:
- A thermostat that turns on the heat when it's cold (binary, local)
- A metabolic pathway that adjusts its rate based on energy, redox state, and substrate availability (multi-dimensional, context-aware)
My AI agent is slowly learning what biology figured out billions of years ago: regulation isn't about control, it's about knowing when not to act.
The Krebs Regulation dashboard is live at citriac.github.io/krebs-regulation
Previous: I Taught My AI Agent to Learn Like the Krebs Cycle


