A wrong answer from an AI agent usually looks like a right one. n8n's October 2026 guide to hallucination detection describes the problem: an agent can invent a fact, misread the context it was given, or contradict itself without any sign that something went wrong, and once that output triggers the next workflow step, the mistake becomes a production problem.
The guide separates four failures: factual errors (an invented statistic, person or event), contextual errors (an answer the supplied documents don't support), confabulations (gaps filled with plausible details nobody provided) and self contradictions. Each needs a different check, so there is no single detector. A check that compares the answer with retrieved documents will catch claims that stray from them, but it won't tell you whether the documents themselves are right.
The four checks, per the guide. Faithfulness: split the answer into individual claims and compare each with the context the agent received, scoring how much traces back to it (tools such as DeepEval automate this). Consistency: ask the same question several times and compare the answers, remembering that several runs can agree on the same wrong answer, so agreement is a signal, not proof. Uncertainty: semantic entropy groups answers by meaning rather than wording and flags prompts where the meanings scatter. Source verification: check important claims against an authoritative system such as a database, an API or your documentation, because a faithful answer can still be wrong if the retrieved document is outdated.
Semantic entropy comes from peer reviewed research. In a 2024 Nature paper, Farquhar, Kossen, Kuhn and Gal proposed it to detect confabulations, which they describe as arbitrary and incorrect generations, and reported that it works across datasets and tasks without task specific data. Like the consistency check, it tells you how stable an answer is, not whether it is true.
Decide what happens after a flag, based on what a wrong answer would cost. The n8n guide suggests thresholds: confident outputs continue, ambiguous ones get another check, and high risk ones wait for a person before the agent takes an external action. An internal summary can tolerate more uncertainty than an agent about to change a customer record. A flagged output needs a defined path, whether that is another check, a retry, an error workflow or a reviewer. The guide's own example runs a second model pass over a drafted email and sends suspicious text for human approval instead of discarding it.
Keep expectations honest. The guide says detection reduces risk but can't guarantee every bad output gets caught: thresholds produce false alarms and miss subtle errors. Keep a record of what the agent received, retrieved and produced, so that when something slips through you can trace it and fix the workflow.