Avoid Agent Hallucinations · Spring AI 2.0

How to keep Spring AI 2.0 agents honest — RAG advisors, typed tools, structured output with schema validation, refuse-on-empty, and eval gates before you trust the loop.

1 · Ground With RAG
QuestionAnswerAdvisor for the fast path
2 · Tools Beat Memory
Live facts → typed tools (price, stock, status)
3 · Shape + Self-Correct
.entity(MyDto.class) for machine-readable answers
4 · Refuse When Empty
Empty retrieval → “I don’t know” / escalate