A model, some tools, a database and a trigger make a working demo. They don't make a production system.
Gartner predicts that over 40% of agentic AI projects will be canceled by the end of 2027, citing escalating costs, unclear business value and inadequate risk controls. That is a forecast, not a measured outcome. One reconciliation of failure statistics notes that it is the only widely quoted figure that measures agents specifically. The scarier numbers (80%, 88%, 89%) cover broader categories such as all enterprise AI or all proofs of concept.
I recently became one of those statistics. I built a six-agent system for petroleum trading and then stopped the project. The reason had little to do with the model or the code.
This article covers the failure data, a layered architecture I would use next time, and my own case. It builds on good existing work, including Event-Driven AI Agents: Patterns That Scale, Designing Agentic AI Systems, Martin Fowler's Long-horizon agents and durable execution and MLflow's Event-Driven Agents.
What the failure data says
- Task reliability: The ShellBench benchmark, built on more than 10 million real-world agent interactions, reports the top model completing 62.5% of tasks on average. Across 53,100 runs, 15.7% failed at least one safety check.
- Repeatability: One model completed 75.1% of tasks at least once across three attempts, but only 48.8% on all three. A single-run evaluation overstates production reliability.
- Correct but unsafe: Of 26,151 runs that met every correctness criterion, 2,589 (9.9%) still failed a safety requirement.
- Where pilots fail: In a Gartner survey of 782 infrastructure and operations leaders, only 28% of AI use cases fully met ROI expectations. Among those who saw failure, 57% cited "expecting too much, too fast" (source).
- Failure modes: One aggregated summary ranks tool errors (about 28%), memory and state issues (about 22%) and unhandled edge cases (about 18%) above hallucination. It aggregates other surveys, so treat these as directional.
Forbes' summary of the Gartner forecast points the same way: governance, data access, ownership and ROI drive cancellations more than raw model capability. Most agent failures are distributed-systems and data problems, so I treat the agent as a distributed system.
Layer 0: Data access
Every architecture guide I read, including the ones linked above, assumes the agent can reach the data it needs. My project shows what happens when that assumption fails. I return to it in the case study below, because it should be checked before anything else.
Layer 1: Event-driven ingress
A request-driven agent waits for a caller. An event-driven agent wakes because something happened, such as a webhook, a queue message or a file change. The broker buffers events when the agent is slow or down. The consumer loop is: subscribe, receive an event, enrich it with tools, reason, then act or choose to do nothing.
Plan for these failure modes:
- Bursts: batch, deduplicate or rate-limit. This also controls cost, since each event can mean several model calls.
- Duplicates: brokers commonly deliver at least once, so derive an idempotency key from the event ID.
- Missed events: run a reconciliation job against the source of truth.
- Silent wrong actions: a crash shows up in your error rate, but a plausible wrong action doesn't.
Use orchestration when one event needs dependent steps, and choreography when several independent agents should react to the same event.
Here is an illustrative handler with an idempotency key and per-event tracing, following the tracing pattern in the MLflow guide. It is a sketch, not production code:
import hashlib import mlflow def idempotency_key(event: dict) -> str: return hashlib.sha256(f'{event["id"]}:{event["type"]}'.encode()).hexdigest() @mlflow.trace def handle_event(event: dict): mlflow.update_current_trace( tags={"event_id": event["id"], "event_type": event["type"]} ) key = idempotency_key(event) if processed_store.exists(key): # your own store (Redis, Postgres, ...) return {"status": "duplicate_ignored"} context = enrich(event) # tool calls appear as spans decision = agent.run(event, context) # "no_action" is a valid result if decision.action == "no_action": processed_store.add(key, outcome="no_action") return {"status": "no_action"} result = act(decision, idempotency_key=key) processed_store.add(key, outcome=result.status) return {"status": result.status} A duplicate delivery now shows up as two traces with the same event_id, and "no action" becomes something you can read instead of a gap in your logs.
Layer 2: Durable execution
Martin Fowler's article describes durable execution as an emerging pattern. The runtime records the result of every step that touches the outside world. After a failure, the program runs again, completed steps are skipped and state is rebuilt from the record. Temporal, Restate, Inngest, DBOS and Cloudflare Workflows implement it. It resembles a write-ahead log, event sourcing and Erlang actors. Waiting workflows hold no process, so cost tracks work done rather than the number of idle agents.
Durable does not mean correct. Fowler's practical rules include:
- Idempotency keys for retries, since at-least-once delivery can cause duplicate actions.
- Expiring approvals, so a stale decision can't be used later.
- Re-checking facts before any hard-to-undo action.
- Approving ranges rather than single values.
- Deterministic rules in code, not in the prompt.
A sketch of such a guard:
class PlaceOrder(Tool): def allowed(self, state) -> bool: return state.approved_up_to is not None and state.order is None async def execute(self, state, ctx): price = await ctx.supplier.current_price(state.sku) # re-check now if price > state.approved_up_to: # outside approved range return Result(placed=False, price=price) return await ctx.supplier.place_order( state.po, idempotency_key=state.po.number # stable across retries ) Notice that this guard depends on current_price returning a real, current number. That is the point I return to below.
Layer 3: Memory
Treat memory as a subsystem, not a vector store. One architecture guide separates working memory from long-term episodic, semantic and procedural memory, with explicit write and read paths and a feedback loop. Start simple. One source argues that below roughly 50K notes, text search with a capped output can beat a vector database. The open-source gbrain project defaults to embedded PGLite for personal use up to about 50K pages. It moves to Postgres with pgvector for shared or large deployments.
Layer 4: Governance and observability
Bain describes three layers for an agentic platform: orchestration, observability and governed data access. Its components include a central registry and policy, runtime guardrails such as prompt-injection filters, and full tracing of the execution graph. A research reference framework adds policy enforcement on every tool call, permission separation by role, bounded execution budgets and immutable audit logs.
For event-driven agents, tracing matters more than for chat agents, because nobody is watching. For any event you must be able to say what the agent received, which model and tool calls it made, and why it acted or didn't. Build an evaluation set from real events, including "no action" cases.
My case: six agents and no data
I built Hanna AI, a prototype multi-agent system for petroleum and petrochemical trading. According to its README, it has six specialized agents covering market analysis, logistics, documentation, compliance, finance and operations. A keyword-based router sends each message to the right agent, and the operations agent coordinates deals. It runs on Next.js, TypeScript and SQLite via Prisma.
The design looked complete. The problem was upstream of the design.
What I could not get. I could not obtain up-to-date data for the oil-related industries I was targeting, because I had no access to it. I also could not find clear, transparent data on suppliers and buyers.
What it did to the build. Real-time prices became mock feeds for 12 products. The company directory became a static list of about 20 companies. The agents could produce fluent answers, but not answers anyone should trade on.
What it did to each layer:
- Ingress: Nothing triggered the agents except a user typing a message, because there was no live feed to emit events.
- Memory: Static or mock records produce confident answers built on old or invented facts.
- Governance: The compliance agent is meant to screen counterparties against lists such as OFAC/SDN. Without a verified, current source, its output is at best a draft for a human. In trading, a plausible wrong screening result is worse than no result.
The durable-execution guard above fails for the same reason. It can re-check a price before an order, but only if a real price exists.
Why I stopped. Without current market data and without transparent information on who supplies and who buys, the system could only demonstrate its workflow, not support real decisions. I chose to stop the project rather than present mock output as if it were reliable. The project is currently on hold.
What I would do differently:
- Check data availability first. List the required sources, confirm access and test freshness before writing any agent code. In my case the six-agent design was the easy part.
- Label prototypes honestly. A demo with mock data can look finished. Mine was described as production-grade while the price feeds were mock, and I would now call it a proof of concept from day one.
- Let agents say "no current data". Treat it as a valid outcome, just like the "no action" path in Layer 1.
- Keep a human on compliance-dependent decisions. In regulated domains, a person should approve anything that relies on a sanctions or counterparty check.
Reference stack and build order
| Layer | Core pattern | Main risk it addresses |
|---|---|---|
| 0. Data access | Verify sources, freshness and rights | Building on data you can't get |
| 1. Ingress | Event bus, dedup, idempotency keys | Bursts, duplicates, missed events |
| 2. Execution | Durable workflows, retries, compensation | Crashes, lost state, long waits |
| 3. Memory | Layered, simple-first | Stale or oversized context |
| 4. Governance | Central policy, audit, tracing, evaluation | Silent wrong actions, compliance |
Add guardrails and observability before complexity (Neo4j makes a similar point). A sensible order:
- Confirm data access.
- Make every handler idempotent.
- Trace every event from day one.
- Move business rules out of prompts and into code.
- Add durable execution once agents wait on humans or external systems.
- Add multi-agent orchestration and a registry last.
Fowler's closing point fits my experience: the trade-offs you build into the harness decide whether an agent is useful or only a proof of concept. I would add one more rule: confirm the data exists before you build the harness.
Sources worth reading
- Gartner press release on agentic AI cancellations
- AI Agent Failure Rate 2026: The Real Data, Reconciled
- Long-horizon agents and durable execution (Martin Fowler)
- Event-Driven Agents (MLflow)
- The Three Layers of an Agentic AI Platform (Bain)
- Inside an enterprise AI agent (AWS Architecture Blog)
Author: Seyed Alireza Alhosseini Almodarresieh
my site:https://almodarresieh.github.io/