MCPWorks

Why 40% of AI Agent Projects Will Fail — And How Proper Infrastructure Prevents It

Simon Carr

Gartner predicts 40% of agentic AI projects will be cancelled by 2027 — not because the AI doesn't work, but because of cost, unclear ROI, and inadequate risk management. The demos are impressive. The production deployments are where projects die.

Security researcher Iain Harper frames it well: AI agent security is roughly where web application security stood in 2004. Twenty-two years behind. The difference is that agents have write access to production systems from day one.

Six ways production agents fail

Harper identifies six documented failure modes that kill agent projects in production:

Prompt injection — hidden instructions manipulate agent behavior. 73% of assessed deployments are vulnerable according to OWASP's Top 10 for LLM Applications 2025.

Runaway loops — agents enter infinite retry cycles and consume cloud budgets overnight. One bad tool call triggers a cascade of retries, each burning tokens, until someone notices or the budget runs out.

Context confusion — long conversations exceed context windows. The agent forgets earlier requirements and starts contradicting itself. Users lose trust.

Confident hallucination — the LLM fabricates data with complete confidence. The agent executes based on information that doesn't exist.

Tool misuse — the agent selects the correct tool but executes it incorrectly. Wrong parameters, wrong order, wrong context. The function runs successfully — with the wrong inputs.

Model versioning — the hosted LLM API changes behavior without warning. An agent that worked yesterday breaks today because the model was updated.

Two of these (hallucination and model versioning) are fundamentally AI model problems. But four of them — prompt injection, runaway loops, context confusion, and tool misuse — are infrastructure problems. They're solvable at the platform layer.

The six-layer defence nobody builds

Harper proposes a defence-in-depth architecture with six layers:

Layer Purpose
Input sanitization Clean and validate data before AI processing
Injection detection Identify manipulation attempts in prompts
Agent execution Control capabilities and contain blast radius
Tool call interception Review and approve high-risk actions before execution
Output validation Check responses before delivery
Observability and audit Monitor everything, log decisions not just actions

Most teams building AI agents implement zero of these layers. They connect an LLM to some tools, get a demo working, and ship it. The agent runs with full access to everything, no execution limits, no approval gates, no audit trail.

This is the gap that kills projects. Not the AI — the infrastructure around the AI.

Limiting the blast radius

Harper's number one practical recommendation: limit the blast radius. When an agent misbehaves — and it will — the damage should be contained.

This means:

Sandboxed execution. Every function call runs in an isolated environment. An agent that goes wrong can't access other users' data, can't escape to the host system, can't consume unlimited resources. At MCPWorks, we use nsjail with Linux namespaces, cgroups, and a seccomp syscall allowlist. Each execution is a fresh sandbox with no persistence.

Hard execution caps. No overage billing. When you hit your execution limit, calls stop. An agent in a runaway loop can't spend $10,000 overnight because the platform enforces the ceiling.

Per-agent access control. Not every agent needs access to every function. A content bot shouldn't be able to call billing functions. A monitoring agent shouldn't be able to delete data. Least privilege isn't a nice-to-have — it's what prevents a prompt injection from becoming a data breach.

Namespace isolation. Each account is fully separated. A vulnerability in one tenant's function cannot affect another tenant's data or execution.

The HITL question

Human-in-the-loop approval is emerging as an industry consensus for high-risk operations. LangGraph has interrupt(). Amazon Bedrock has built-in confirmation. HumanLayer routes approvals through Slack and email.

The pattern is the same everywhere: some function calls should require human approval before execution. Delete operations, financial transactions, external communications — these shouldn't fire automatically just because an LLM decided they should.

The teams that build this into their agent infrastructure survive. The teams that don't are the 40%.

The cost equation

The Gartner stat isn't just about security — it's about total cost. Running AI agents in production means paying for:

  • LLM API calls (tokens per operation)
  • Compute for execution
  • Engineering time for security and reliability
  • Incident response when things go wrong

Most of the cancelled projects will be killed by the gap between "it works in a demo" and "it works reliably at scale without bankrupting us or exposing customer data." That gap is an infrastructure problem, and it has infrastructure solutions.

The question isn't whether your AI agent is smart enough. It's whether the platform running it is secure enough, efficient enough, and observable enough to survive production.

Forty percent of projects won't make it. The infrastructure layer determines which forty percent.

MCPWorks is open source.

Self-host free forever, or try MCPWorks Cloud — 14-day Pro trial, no credit card.

View on GitHub Cloud Trial — Coming Soon