Most developers obsess over LLMs saying wrong facts, but the real production nightmare is an agent executing a write action on a hallucinated ID. A new two-part series from Vivek Daily on DEV.to argues that while content hallucinations require expensive semantic judges, action and outcome hallucinations are structural problems that can be caught with near-zero cost using simple trace analysis. The distinction is critical: a wrong statistic annoys a user, but a refund sent to a non-existent order ID moves real money.
The Three Types of Agent Hallucination
The article categorizes agent failures into Content (unsupported claims), Action (invented tool arguments), and Outcome (claiming success without execution). Content issues need model judgment, but Action and Outcome issues leave clear fingerprints in the execution trace. For example, if an agent calls refund_order(order_id="ORD-44718") and that ID never appeared in the prior conversation history, tool results, or retrieved context, it is a structural error. The proposed solution is a provenance check that verifies every identifier passed to a write tool exists in the previous spans of the trace.
Cheap Checks That Save Your Wallet
Implementing these checks requires about forty lines of Python. The first check, Argument Provenance, scans write tools for identifiers like order IDs or emails and ensures they appear in the history before the call. The second check, Claim vs. Trace, compares the agent's final natural language response against the actual successful tool calls. If the agent says it sent an email but the trace shows no successful send_email call, the system flags it. These checks run on every request because they are deterministic and fast, blocking bad actions before they execute rather than just logging them post-hoc.
Prevention Through Design
Beyond detection, the guide recommends three design patterns to reduce hallucination rates. First, prevent the model from typing IDs from memory by forcing it to select from indexed results in tool responses. Second, require a confirmation step where the agent restates the target ID and amount, which is then validated against the trace. Third, generate the final user-facing reply from the structured tool results rather than letting the model freeform its own summary. These steps shrink the gap between what the model intends and what it actually does.
Key Takeaways
- Action and outcome hallucinations are structural and can be caught with cheap, deterministic trace checks.
- Argument provenance checks ensure IDs and amounts passed to write tools exist in the prior conversation context.
- Claim-vs-trace validation compares the agent's final text response against the actual successful tool calls.
- Design patterns like index-based selection and confirmation steps prevent hallucinations before they occur.
The Bottom Line
Stop paying for expensive semantic judges when you can catch the most damaging errors for free. Structural trace analysis is the most cost-effective guardrail for production agents, catching action and outcome hallucinations before they move real money or mislead users.