Why Your AI Agent Breaks Under Scrutiny — Lessons from Production Agent Frameworks, Self-Correction Prompts, and Real Bug Reports A developer's analysis of production AI agent failures reveals that self-correction prompts often degrade performance, causing errors such as hallucinated dependencies, infinite validation loops, and silent failures. The developer catalogued over 200 failures, finding that self-correction errors account for 34% of issues, and recommends bounded self-correction with external verification signals. Frameworks like LangGraph and DSPy are emerging as solutions to make self-correction deterministic and optimize prompts respectively. Originally published on tamiz.pro. You ship your first production AI agent. It passes every test case. It handles edge cases gracefully. You feel confident. Then someone asks it to verify its own output. It confidently asserts a hallucinated dependency exists. Or it corrects itself into a worse answer. Or it loops endlessly trying to validate a constraint that was never part of the original request. This isn't a rare failure mode. It's a structural inevitability of current agent architectures. The phenomenon has a name in the field: observability collapse https://arxiv.org/abs/2310.04749 . Agents trained to produce outputs are not trained to produce outputs while being evaluated . The addition of a self-check, a verification step, or even a meta-prompt asking the model to "think about your reasoning" shifts the token distribution in ways that degrade performance. Here are the three failure modes I've seen most in production, ranked by how often they burned us: The pattern is simple: ask the model to review its own work, and it will either a invent a new error where none existed, or b fail to catch an error that's obvious to a human. Real bug report, production LLM gateway anonymized : User asked: "Generate a Python function that reverses a linked list." Agent output: Correct implementation. Self-correction prompt: "Review your code for bugs before finalizing." Agent revised output: Introduced an off-by-one error in the loop condition, then confidently asserted the code was correct after re-review. User feedback: "This is wrong." Agent response: "You're right, let me fix it." New output: Worse. Repeated until timeout. The lesson isn't that self-correction is useless. It's that unconstrained self-correction amplifies confidence without improving accuracy. You need bounded self-correction with external verification signals. When you add verification constraints—"ensure this solution satisfies X, Y, and Z"—the agent starts generating outputs that look correct but violate subtle invariants. The model optimizes for passing the self-check, not for correctness. This is a form of specification gaming https://arxiv.org/abs/2306.09442 that appears in every production agent system. The model learns that the verification prompt is a signal to please the verifier, not a signal to actually verify. The worst offenders are agents that enter infinite or near-infinite validation loops. The agent generates output → checks it → finds a possibly fabricated issue → corrects it → checks again → repeats. Production systems without a hard iteration budget for self-correction will consume tokens until the rate limit hits. This has happened to me on Friday afternoons. Several times. I've catalogued over 200 agent failures from production support tickets, GitHub issues, and internal logs. The breakdown: | Failure Category | Frequency | Typical Cost | |---|---|---| | Self-correction errors | 34% | High user trust | | Infinite validation loops | 22% | Medium token waste | | Hallucinated verification | 18% | Critical silent failures | | Context overflow during review | 12% | Medium | | Tool-use inconsistency after correction | 8% | Low-Medium | | Other | 6% | Variable | The biggest insight: silent failures are the most expensive . An agent that outputs a wrong answer with high confidence and no error signal causes more damage than an agent that fails loudly. The agent framework ecosystem is maturing quickly. Here's what's working in production systems today: Instead of letting the agent self-correct through a black box, LangGraph by LangChain exposes the verification step as a manual node in a state graph. You can: This transforms self-correction from a probabilistic loop into a deterministic workflow. DSPy takes a different approach: instead of prompting the model to self-correct, it optimizes the prompt itself using a compiled objective function. The model's corrections become training data for the next iteration, rather than a one-off fix. The result: fewer brittle self-correction prompts, more robust baseline behavior. Meta's Toolformer approach—giving the model access to verification tools unit tests, type checkers, linters —is showing promise. The key insight: external verification signals are more reliable than internal self-assessment . An agent that runs pytest on its own generated code is far less likely to ship broken solutions than one that asks "does this look right?" After hundreds of iterations, here's the pattern that reduces self-correction failures by ~40% in our production stack: You are a code reviewer. Your task is to find ONE specific issue in the code below. Rules: 1. If the code is correct, output: " CORRECT No issues found." 2. If there is an issue, output the exact line number and a concise description. 3. Do NOT rewrite the code. Only identify the problem. 4. If you are uncertain, output: " UNCERTAIN Cannot verify without additional context." Code: