DEV Community

john Clent Oira
john Clent Oira

Posted on

Everyone Is Building AI Agents. But Who Is Making Them Reliable? πŸ€–β˜•

I've been thinking about something lately.
We spend so much time discussing how intelligent AI agents can become, how many tools they can use, and how independently they can operate.

But I wonder if we're asking the wrong questions.
What happens when an agent makes a perfectly reasonable decision that produces a completely unacceptable result?

The demo was perfect. Production had other plans.
Imagine you've built an AI agent that helps customers manage their orders.
A customer asks for a refund. The agent understands the request, checks the order details, verifies eligibility, and calls the refund API.
The payment service successfully processes the refund, but the connection times out before the agent receives confirmation.
From the agent's perspective, the operation might have failed.

So it tries again.
And now the customer potentially receives two refunds.
The model didn't hallucinate. It understood the request correctly. It selected the appropriate tool. Even its decision to retry was understandable.
The problem was somewhere else entirely.
The system allowed an uncertain outcome to become another potentially irreversible action.
Suddenly, that impressive five-minute AI demo looks a little different. πŸ˜…

Are we reinventing problems we've already solved?
What's interesting is that many of the challenges surrounding AI agents aren't particularly new.
Distributed systems have struggled with partial failures, duplicate requests, inconsistent state, and network uncertainty for decades.
Yet when we talk about agentic AI, these problems sometimes receive less attention than model intelligence and autonomous reasoning.
A production-ready agent needs more than good prompts and well-defined tools:
Idempotency: Repeating the same operation shouldn't produce unintended side effects.
State management: An agent needs to distinguish between a failed operation and one whose outcome is unknown.
Permission boundaries: Having access to a tool doesn't mean every possible action should be authorized.
Observability: Developers need to understand why an agent made a decision, which tools it called, and what actually happened.
Recovery mechanisms: Systems need a way to reconcile uncertain outcomes instead of blindly retrying.

Human oversight: Some decisions are simply too consequential to leave entirely to an autonomous system.
None of these sound particularly revolutionary.
And perhaps that's exactly the point.
MCP makes things easier, but not necessarily safer
I find MCP fascinating because it simplifies how AI applications discover and interact with external tools.

But standardizing access to tools doesn't automatically solve the problems associated with executing them.
A tool called refund_payment might be easy to expose through MCP. Making that tool safe under retries, concurrent requests, partial failures, and unexpected agent behavior requires considerably more thought.

For instance, should an LLM decide whether to retry a payment operation?
Or should that decision belong to a deterministic execution layer that checks transaction status, enforces idempotency, and validates permissions independently of the model?
I'd lean toward the second approach.

Let the model reason about intent. Let the infrastructure enforce the rules that must never be broken.
The uncomfortable side of autonomy
There's also a human aspect to all of this that I don't think we discuss enough.
We build autonomous systems because we want to reduce human workload. But if those systems are unpredictable, developers end up spending their time monitoring, debugging, and correcting them.

Have we actually saved time, or have we simply exchanged one kind of work for another?

An agent that completes 100 tasks independently but requires constant supervision may be less valuable than a more constrained agent that developers can genuinely trust.
More autonomy isn't necessarily more progress.
Sometimes, introducing a limitation is the better engineering decision.

Perhaps boring engineering deserves more attention
Reliable systems rarely make exciting demonstrations.
Nobody gets particularly excited about a properly implemented idempotency key, a predictable state machine, or a permission check that quietly prevents an unauthorized operation.
Until something goes wrong.
Then those boring engineering decisions become the most valuable parts of the entire system.
I suspect the next major breakthrough in agentic AI won't come exclusively from smarter models. It may also come from building infrastructure that makes imperfect intelligence dependable.

I'd love to hear your thoughts β˜•
If you were designing an AI agent for a production system today, where would you draw the boundary between autonomous reasoning and deterministic execution?
Should reliability guarantees eventually become a standardized part of protocols like MCP, or should they remain the responsibility of individual applications and tool providers?
I'm particularly interested in hearing from developers who have moved beyond prototypes and encountered these challenges in real systems.
Sometimes the most interesting conversations in software engineering begin with a simple question:

Just because we can automate something, should we?

Top comments (7)

Collapse
 
maxmartella profile image
Massimiliano Martella •

the timeout case stands out to me... If a refund call times out, the status is β€œunknown,” not β€œfailed”... I would check the paymnt status using an idempotency key before retrying...
For MCP tools: should that key be generated per user request or per tool call?

Collapse
 
userxnom profile image
Abdullah Naseer •

The double-refund scenario is the perfect example because nothing in it is a model failure β€” the agent did everything right and the system still produced the wrong outcome. The detail I'd add is that idempotency only works if the key is generated once, before the first attempt, and reused across every retry β€” if the agent mints a fresh key each time it retries, you've just built a machine for duplicate refunds with extra steps. And the unknown-outcome state needs a reconciliation path, not a retry: check the payment provider by that key before doing anything else. I agree with your split β€” the model decides intent, a deterministic layer decides what is allowed to happen. Where would you draw the line in practice: are there operations you'd never let an agent retry at all, even with idempotency in place β€” say, refunds above a certain amount going straight to a human queue?

Collapse
 
johnclentoira profile image
john Clent Oira •

Great points, Abdullah! I especially appreciate the distinction between reconciliation and blindly retrying.
I'd draw the line based on financial impact, reversibility, and business risk. Small refunds could be automated, while larger or suspicious transactions should require human approval. Cumulative limits matter too: ten $100 refunds can be just as risky as one $1,000 refund.
The model can recommend actions, but an independent policy should enforce the boundaries.
I'm curious: would you enforce these safeguards centrally in the orchestration layer or within each individual service? I'd favor service-level enforcement for critical operations.

Really enjoying this discussion! πŸ™Œ

Collapse
 
userxnom profile image
Abdullah Naseer •

I'd do both, but for different reasons. The policy itself should live centrally β€” one place that defines what's allowed, so every service agrees on the same limits and there's a single audit trail. But the enforcement also has to sit inside each service for the critical operations, because if the orchestration layer is ever bypassed or compromised, a service that blindly trusts the caller has no second line of defence. So: central policy, local enforcement for anything irreversible. Your cumulative-limits point is a good example of why the central view matters β€” no single service can see ten $100 refunds adding up.

Thread Thread
 
johnclentoira profile image
john Clent Oira •

I really like that approach, Abdullah! Having a central policy while letting individual services enforce their own safeguards seems like a sensible balance.
It also makes me wonder what happens when the central policy service becomes unavailable. For irreversible operations, I'd rather block the action than risk relying on outdated permissions.
It's interesting how so many AI agent challenges eventually come back to traditional software engineering principles.
Really enjoyed exchanging ideas with you. Thanks for sharing your perspective! πŸ™Œ

Collapse
 
leob profile image
leob • • Edited

Yeah good points - so, how to go about it? I'm calling it "common sense" and "basic best practices (in software engineering)" - I think all the principles that we've used for years still apply (well, they should) ...

The only thing that's fundamantally different is that AI is non-deterministic, so you have to take that into account when designing/architecting a system ... strong guardrails is what you need, but arguably in many cases you also need that with "conventional" (non-AI) systems of a certain complexity!

Collapse
 
nexusverify profile image
Nexus Verify •

Treat a timed-out refund as unknown, never as failed. Before any retry, read the payment state with the same idempotency key you sent the first time β€” if the provider returns the original refund, stop there; only retry with that same key, never a new one. A concrete check: send a refund, drop the connection before the response arrives, then query by that same key and confirm you get exactly one refund, not two.