WhoBuilt

Stop AI Agent Hallucinations: 5 Techniques + Production Patterns

Jul 11, 2026· 55 min· 3.9K views·Watch on YouTube

Speaker

Elizabeth Fuentes León, an AWS developer advocate focused on agentic applications, presents five code-based techniques for reducing AI agent hallucinations, using a Strands travel agent demo.

Select only relevant tools

Fuentes explains that sending all 29 travel-agent tool descriptions on every request can add about 3,000 tokens. Semantic search can select the two or three most relevant tools, reducing tool-context tokens to fewer than 300. For conversations, she also swaps tools between invocations so unused tools do not accumulate in the agent state.

Use graph queries for precise answers

Vector retrieval can miss dataset-wide counts, averages, and relationships because it returns only a few text chunks. Fuentes compares a vector-search agent with a Neo4j graph agent that generates Cypher queries to compute answers across the data. In her examples, the graph query returns an average hotel rating of 47 and reports no hotels with pools or in Antarctica.

Validate agent actions with other agents

A single agent may receive a tool error yet still report that an action succeeded. Fuentes uses a Strands Swarm with an executor, validator, and critic: the executor acts, the validator checks the result, and the critic approves or rejects it. In a booking demo, the extra checks catch an error for a nonexistent hotel and prevent a fabricated confirmation.

Enforce hard rules in code

Fuentes says prompts can be treated as suggestions, so she uses Strands hooks to inspect tool parameters before execution. Her demo rules include checking that check-in precedes check-out, limiting bookings to 10 guests, and requiring verified payment before confirmation. The hook blocks a booking that violates a rule, even when the prompt-only agent proceeds.

Steer soft rules and plan for production

For rules where the agent can adjust its plan, Fuentes demonstrates Agent Control steering: a request for 60 guests is handled by splitting the reservation across rooms. She then describes a production setup with Amazon Bedrock AgentCore for runtime, gateway, memory, and observability; steering rules live in DynamoDB and can be changed without redeploying the agent.

Takeaways

  • Filter tool schemas per request to reduce token use and avoid exposing irrelevant tools.
  • Use graph queries for dataset-wide counts and aggregates that sampled retrieval cannot reliably compute.
  • Add an independent validation pass when tool failures could otherwise become false success reports.
  • Put hard business rules in executable checks before tools run.
  • Use steering for recoverable constraints, and keep changeable rules outside the deployed agent code.

Mentioned in this talk

Search inside this talk

What was claimed 11

Related talks