The Demo–Production Gap Is Real, and It's Measurable
The demo worked flawlessly. Two weeks in production, the same agent emailed a customer a fabricated tracking number, stalled for four minutes on a slow endpoint, and burned through a token budget meant to last a month. If you've shipped an LLM agent, some version of this has happened to you.

After our third rollback, we stopped patching symptoms and started tagging every failed run. Three months and a few hundred tagged failures later, seven patterns explained nearly all of them. Below is each pattern with the symptom, what we changed, and the before/after numbers from our own stack — plus the detection signal you can watch for starting today.

The Seven Patterns
1. Hallucination Loops
Symptom: the agent reports data it never retrieved, or repeats the same failing call with cosmetic tweaks — six times, eight times, ten.
On our invoice-matching agent, 17% of runs ended this way before we fixed it. Two changes got us under 2%. First, we made "not found" a first-class tool output instead of an empty result the model felt free to improvise around. Second, we added a loop detector: hash the tool name plus arguments, and if three near-identical calls land in one run, halt and escalate. We also require claims in the final answer to reference a tool_call_id from the trace. Fabrications now fail loudly instead of silently shipping.
Detection signal: the same tool called three or more times with near-identical arguments in a single run.
2. Tool Call Timeouts
Symptom: one slow endpoint freezes the whole run while the user watches a spinner.
Our p95 run latency sat around four minutes because a legacy ERP report endpoint took 60–90 seconds, and we waited synchronously. Moving anything slow to an async job pattern — submit, get a job_id, poll or resume on callback — dropped p95 to roughly 70 seconds and cut timeout failures from 9% of runs to under 1%. Note: our 30-second cutoff for synchronous calls is our heuristic, not an industry standard. Tune it to your users' patience and your endpoints' real latency.
Detection signal: p95 step latency creeping above twice your median, or timeout errors on the same endpoint more than once a day.
3. Context Overflow
Symptom: the agent pastes entire API responses into history. A single 50-record JSON blob can easily eat a thousand-plus tokens, more if records are wide or pretty-printed. By step ten the window is stuffed with stale payloads, and the model starts ignoring its own instructions.
Once we stopped appending raw tool output — summarizing results into compact notes, keeping at most the last two raw outputs, storing full payloads externally with an ID the agent can re-fetch — average token use per run fell from about 180k to 40k, and cost per completed task on our research agent dropped from roughly $0.84 to $0.19.
Detection signal: per-run token usage climbing step over step with no plateau, or system instructions falling out of the effective context.
4. Malformed Tool Arguments
Symptom: the model emits JSON with a renamed field, a date in the wrong format, or a string where a number belongs. The tool returns a 400, and the agent starts improvising.
Malformed calls caused 14% of failures on our CRM-writing agent. A validation layer that checks arguments against a JSON Schema before execution — and bounces the validator's exact error message back to the model, not a generic "error" — cut that to about 1.5%. One corrective retry, then escalate to a human. The function calling docs cover schema basics; the production difference is enforcing them before the tool runs, not after.
Detection signal: rising 400s from your own tools, or retries where only one argument changed.
5. Retry Storms
Symptom: a failing dependency triggers retries at every layer — the agent retries, the framework retries, the SDK retries — and the bill explodes.
Our worst incident was a single overnight run costing about $210. The intended cost was roughly $3. The fix was boring and non-negotiable: retry budgets at each layer that draw from one shared per-run budget, hard token and dollar caps per run, and a circuit breaker that disables a tool after consecutive failures. Monthly spend variance went from ±60% to ±8%.
Detection signal: any run costing three times the rolling median, or one tool consuming more than half a run's budget.
6. Prompt and Model Drift
Symptom: nothing in the code changed, but Wednesday the agent formats summaries wrong. A "tiny" prompt edit or a silent model version bump did it.
We pin model versions explicitly and run a 40-task golden-set eval on every change to a prompt, model, or tool definition. Of our last four regressions, three were caught in CI before deploy; before the eval suite existed, we found them in production, usually via a customer. Diff the tool-call traces, not just final answers — most drift shows up as changed intermediate behavior.
Detection signal: any deploy touching prompt, model, or tool definitions without a green eval run.
7. Goal Drift on Long Tasks
Symptom: twenty steps in, the agent is reformatting a spreadsheet nobody asked for and has forgotten the actual objective.
Completion on 25-plus-step tasks sat around 40% for us. Re-injecting the original goal and done-criteria every 12–15 steps — our heuristic interval, not a universal rule; tune it to your task length — lifted that to roughly