7 real-world failures and fixes from building agentic systems
Published: 2026-01-06
URL: https://sumantthakur.substack.com/p/agent-patterns-i-wish-i-knew-before
Agentic systems are not clever chatbots. They are production systems that reason probabilistically and then act on real infrastructure, real data, and real users. The first time an agent opens a destructive pull request, loops until your cloud bill explodes, or quietly follows a malicious instruction hidden inside a document, you stop thinking about prompts and start thinking about architecture.
This post is a distillation of hard lessons. These are seven failure patterns I’ve seen repeatedly while building and reviewing agentic systems, why they happen, and the concrete fixes that actually work in production. If you’re building agents that do more than answer questions, this is the checklist I wish I had earlier. Agents fail in predictable ways.
Most failures are architectural, not model-related. The fix is almost always structure, verification, and limits, not “better prompting”. Thanks for reading Autonomous AI Architect! Subscribe for free to receive new posts and support my work.
- Hallucination that turns into action
What it looks like An agent confidently claims a resource exists and proceeds to modify or delete it. Or it invents a dependency, API, or configuration that never existed. Why it happens LLMs optimize for plausible continuation, not truth.
When planner output is treated as fact instead of a hypothesis, hallucinations turn into real-world side effects. What actually fixes it Planner → Verifier split The planner proposes actions. A separate verifier re-checks every claim against authoritative sources before execution. Structured plans only No free-form text for actions. Plans must be machine-validated JSON. Dry runs by default Simulate the plan and compare predicted vs actual diffs before executing anything destructive. Rule of thumb If a model output can change state, it must be verified by code.
- Context drift and memory inconsistency
What it looks like Different agents disagree on state. The system repeats work, contradicts itself, or acts on stale assumptions. Why it happens Long-running agent workflows accumulate partial memory. Without a canonical source of truth, “memory” becomes folklore.
What actually fixes it Single canonical state store One write path. One source of truth. Versioned memory Every read and write includes a version. If it’s stale, the agent must refresh. Short-lived working context Keep planning context short. Revalidate before execution. Rule of thumb Agents can think freely, but state must be boring and centralized.
- Prompt and task injection
What it looks like An uploaded document or third-party payload contains hidden instructions that the agent follows. No exploit, no bug, just obedience. Why it happens Agents often concatenate external content directly into prompts. Models cannot inherently distinguish “instructions” from “data”.
What actually fixes it Treat all external text as data Explicitly label it as non-executable content. Semantic sanitization Detect instruction-like patterns and escalate. Privilege gates Sensitive actions require explicit approval or higher-trust tokens. Sealed system instructions Never allow user-controlled content to override system rules. Rule of thumb Untrusted text must never directly influence decisions.
- Runaway loops and agent chains
What it looks like An agent retries endlessly, spawns sub-agents, or keeps calling tools with no state change. Costs rise silently. Why it happens Planning without termination conditions plus delegation equals infinite loops.
What actually fixes it Hard execution limits Max steps, max wall time, max token budget. Loop detection Halt if actions repeat without state changes. Economic circuit breakers Stop or degrade behavior when budgets are exceeded. Controlled delegation Spawning agents requires explicit approval. Rule of thumb Every agent run must be finite by design.
- Tool misuse and permission escalation
What it looks like Agents call admin APIs they shouldn’t have access to, or chain tools to escalate privileges indirectly. Why it happens Overly broad tool interfaces and implicit trust between agents and tools.
What actually fixes it Least-privilege tools Expose narrow, intention-specific APIs. Scoped, short-lived tokens Per-run credentials with minimal permissions. Policy enforcement at the tool boundary RBAC, quotas, and compliance checks before execution. Full audit trails Every action logged with agent identity and rationale. Rule of thumb Agents should never have more power than the task requires.
- Observability blind spots
What it looks like Something goes wrong in production and no one can explain why. Logs exist, but the story is missing. Why it happens Agentic systems are multi-step, multi-model, and tool-heavy. Without correlated tracing, causality disappears.
What actually fixes it Correlation IDs everywhere One ID across planning, verification, tools, and execution. Failure-first tracing Store full traces for failures, sample successes. Playback views Step-by-step reconstruction of what the agent thought and did. Agent health metrics Latency, success rate, policy violations, cost per run. Rule of thumb If you can’t replay an agent run, you don’t understand it.
- Cost surprises
What it looks like A “small” feature quietly racks up LLM calls, retries, and tool usage. Finance notices before engineering does. Why it happens No per-run metering and planners that ignore cost entirely.
What actually fixes it Meter everything Tokens, tool calls, external APIs, infra changes. Cost-aware planning Estimate cost before executing a plan. Graceful degradation Smaller models, fewer retries, or partial execution near limits. Alerts tied to anomalies Not just absolute spend. Rule of thumb If agents don’t know cost, they will abuse it.
A practical order of operations If you’re building or hardening an agentic system, do this in order: Add quotas, budgets, and hard stops Introduce planner → verifier separation Centralize state and memory Implement tracing and playback Lock down tool permissions Only then optimize prompts and models Minimal production checklist Copy this and keep it close: Planner outputs validated JSON Verifier checks authoritative APIs Single transactional state store External inputs treated as data Max steps and budget enforced Scoped short-lived tool tokens Correlated traces per run Dry-run support for risky actions Cost estimated before execution Human approval for privileged actions