Your AI Agent Didn’t Crash. It Still Failed.
The production controls — contracts, evidence, tracing, recovery, and approvals — that matter more than another prompt tweak.
Imagine a support agent that receives a ticket, searches the knowledge base, checks the customer’s account, drafts a reply, and updates the CRM.
Every service returns 200 OK. The workflow completes. The dashboard stays green.
The answer is still wrong.
The agent retrieved an outdated cancellation policy, confused two subscription tiers, and wrote a confident response that created a real customer problem. Nothing crashed, so conventional monitoring recorded a success.
This is an illustrative scenario, but the failure pattern is real: an AI system can be operationally healthy while being functionally wrong.
That is the gap between an impressive agent demo and a dependable production system. A better prompt may improve average behavior. It does not give you contracts, evidence, permissions, recovery, or accountability.
Production agents should be treated as distributed systems with probabilistic decision-makers inside them — not as prompts wrapped in API calls.
1. Define success outside the model
Many teams let the agent decide whether it completed the task. That is convenient, but it creates a circular test: the component producing the result is also grading itself.
Define an outcome contract that code can check.
For the support workflow, a valid result might require:
- a recognized intent;
- a customer identifier that matches the authenticated user;
- policy evidence newer than a defined freshness limit;
- a response that cites the policy version used;
- no account mutation without explicit authorization; and
- a structured status such as
resolved,needs_review, orinsufficient_evidence.
The model can propose an outcome. The surrounding system should verify the invariants.
A confidence score is not a substitute. Models can be confidently wrong, and an arbitrary threshold does not prove that the right evidence or authorization was used.
2. Treat every tool call as an untrusted request
An agent calling a tool is similar to a user calling an API. The request may be malformed, unauthorized, duplicated, or based on bad context.
Tool boundaries need the same engineering discipline as public endpoints:
- validate arguments against a strict schema;
- separate read tools from write tools;
- use the narrowest permission scope available;
- enforce timeouts and bounded retries;
- require idempotency keys for repeatable writes;
- return typed errors the orchestrator can handle; and
- reject actions that violate business rules, even when the model requested them.
The model should never be the final authority on what it is allowed to do.
This matters because the blast radius grows with agency. OWASP describes “excessive agency” in terms of excessive functionality, permissions, or autonomy. A useful design question is therefore not only “What can this agent do?” but “What is the smallest capability it needs for this step?”
3. Context is a data pipeline, not a large text box
When an answer is wrong, teams often add more context. That can make the problem worse.
Production context needs provenance and policy:
- Where did this fact come from?
- When was it last updated?
- Is the current user allowed to access it?
- Which version was used for this decision?
- What should happen when sources disagree?
- When should the system abstain?
Separate four things that are often mixed together:
- Durable business state, stored in a system of record.
- Short-lived working state for the current workflow.
- Retrieved evidence used to ground a decision.
- Conversation history, which may contain noise or untrusted instructions.
More tokens do not automatically create better reasoning. They can bury the relevant fact, preserve stale information, and carry malicious instructions from one step into another.
4. Trace decisions, not only requests
Traditional observability answers questions such as:
- Did the request succeed?
- How long did it take?
- Which dependency failed?
Agent observability must answer a second set:
- Which evidence influenced the decision?
- Which tools were available and which were called?
- Which model, prompt, and policy versions were active?
- Where did the workflow branch?
- What was retried, and why?
- Which guardrail or approval changed the outcome?
Store a trace that connects the user’s request, retrieved evidence, model decisions, tool calls, validations, approvals, and final outcome. Redact sensitive data, but preserve enough structure to reproduce a failure.
Get Mango Orbit’s stories in your inbox
Join Medium for free to get updates from this writer.
Then build evaluations from real traces. Start with known failure cases and messy edge cases — not only clean examples written during development.
Useful measurements include task success, unsupported claims, tool-selection accuracy, policy violations, recovery rate, human-escalation rate, latency, and cost. Token usage alone tells you almost nothing about whether the task was completed correctly.
5. Design for interruption and recovery
Long-running agents combine model calls, network requests, queues, databases, and third-party APIs. At least one step will eventually fail.
Restarting the entire workflow is often unsafe. It may repeat an email, create a second ticket, or apply the same account change twice.
Use durable checkpoints around meaningful steps:
- record the workflow state before external actions;
- make writes idempotent;
- distinguish retryable failures from permanent ones;
- cap retries and use backoff;
- preserve failed work for inspection; and
- resume from the last verified checkpoint.
The goal is not to prevent every failure. It is to make failure bounded, visible, and recoverable.
6. Put humans at consequence boundaries
“Human in the loop” is often implemented as approval for everything. That creates alert fatigue and removes the benefit of automation.
Place approvals where consequences become meaningful:
- sending an external message;
- changing money, permissions, or account state;
- publishing content;
- deleting data;
- acting with weak or conflicting evidence; or
- crossing a legal, security, or compliance boundary.
The approval screen should show the proposed action, exact target, important evidence, and expected consequence. A vague “Allow?” button simply transfers uncertainty to the user.
OpenAI’s agent guidance emphasizes layered guardrails and clear tool boundaries. Anthropic similarly recommends starting with the simplest architecture that works, using predictable workflows when the path is well defined and adding autonomy only where flexibility justifies its cost.
That is a useful principle: autonomy should be earned by evidence, not added by default.
7. Give the agent a budget
An agent can succeed technically and still fail as a product because it is too slow or expensive.
Set explicit budgets for:
- model calls per task;
- total tokens;
- tool calls;
- wall-clock duration;
- retry count; and
- maximum financial or operational impact.
When a budget is exhausted, the system should degrade gracefully: return partial verified work, switch to a simpler workflow, or ask for human help. An uncontrolled reasoning loop is not intelligence. It is an outage with a variable bill.
A production-readiness checklist
Before giving an agent real responsibility, ask:
- Is success defined by code outside the model?
- Are tool inputs validated and permissions minimal?
- Are write operations idempotent?
- Does every important claim have traceable evidence?
- Can the system abstain when evidence is weak?
- Can we reconstruct why a decision was made?
- Do evaluations include real failure traces?
- Can interrupted work resume safely?
- Are irreversible actions protected by meaningful approvals?
- Are latency, cost, retries, and impact bounded?
If several answers are “no,” the system may still be a useful prototype. It is not ready to operate independently.
The prompt is only one component
Prompt quality matters. Model choice matters. Neither replaces system design.
A dependable agent needs contracts around its outputs, disciplined context, narrow tools, evidence-aware evaluation, durable recovery, and human control at the right moments.
The most dangerous failure may not produce an exception. It may look exactly like success until a customer, operator, or auditor discovers the consequence.
Which production failure worries you most: silent wrong answers, unsafe tool use, corrupted state, runaway cost, or something else?









