{
  "video": {
    "id": "vJukHCIv7Ck",
    "title": "Stop AI Agent Hallucinations: 5 Techniques + Production Patterns - Elizabeth Fuentes, AWS",
    "duration": 3319,
    "upload_date": null,
    "channel": "AI Engineer",
    "source": "AI Engineer",
    "event_format": "Online"
  },
  "analysis": {
    "video_id": "vJukHCIv7Ck",
    "title": "Stop AI Agent Hallucinations: 5 Techniques + Production Patterns - Elizabeth Fuentes, AWS",
    "one_liner": "An AWS developer advocate shows five anti-hallucination techniques for agents — semantic tool selection, GraphRAG, multi-agent validation, neuro-symbolic hooks and runtime steering — each demoed as a code change in a Strands travel agent, never a prompt change.",
    "summary": "Elizabeth Fuentes Leon argues that prompts are suggestions, not constraints, so hallucinations and token waste have to be fixed in code. Using one dummy travel agent built on Strands Agents (with OpenAI as the model provider), she runs each technique side by side — agent without it, then with it — measuring tokens and accuracy against a ground-truth set of 90 queries over 29 tools. The five fixes are: filter tools into context by vector search, replace text retrieval with a Neo4j/Cypher knowledge graph for aggregation and counting questions, add a Swarm of executor/validator/critic agents, enforce booking rules in Python hooks that fire before a tool call, and use the agentcontrol library to steer rather than hard-block. She closes by mapping each local demo onto Amazon Bedrock AgentCore (Gateway, Runtime, Memory, Policy) for the production version.",
    "key_points": [
      "The travel agent has 29 tools; every tool's generated schema goes into the context window on every single call, adding up to roughly 3,000 tokens per call just for tool descriptions — before the user's message and before the response — and you pay whether the model uses the tool or not.",
      "Semantic tool selection: embed the tool descriptions into a vector store (sentence-transformers running locally and free, a plain file as the store), search the user query, and inject only the top-3 tools. Token usage drops from thousands to fewer than 300; the baseline agent was spending around 2,000 tokens per question.",
      "For multi-turn conversations, filtering alone isn't enough — chat history accumulates — so she clears and re-registers tools via the Strands tool registry inside the agent loop ('swap tools'), because each invocation gives you complete control of agent state.",
      "GraphRAG: vector search 'always returns something even when nothing is truly relevant', and the agent only sees the top-N chunks, so it cannot aggregate, count or traverse relationships — it estimates and presents the estimate as fact. With Neo4j, the model writes a Cypher query that runs across all the data and returns a computed result. Asked about hotels in Antarctica (there are none), RAG waffles about alternative experiences while the graph agent returns a short, honest 'no hotels listed'. She builds the graph from raw .txt with Neo4j's SimpleKGPipeline, which uses an LLM to construct it.",
      "Multi-agent validation: a single agent that gets a tool error rationalizes it and returns a confident success response — 'the user thinks it work, you think it work, it didn't'. Strands' built-in Swarm class chains executor → validator → critic with automatic handoffs (entry point executor, capped handoffs); on a booking for a non-existent hotel the executor errors, the validator catches the hallucination and the critic rejects, so the user sees a clear failure instead of a fabricated confirmation.",
      "Neuro-symbolic guardians: rules written in Python hooks (HookProvider, hook registry, and the before-tool-call event that fires every time the model is about to execute a tool) — check-in before check-out, maximum 10 guests per booking, payment before confirmation, no cancellation within 48 hours of check-in. Same model, same tools, same prompt; the only difference is one line adding the hook, and the outcomes flip from wrong to correct.",
      "Runtime steering: hooks are all-or-nothing and leave the user stuck retrying, and changing a rule means changing code and redeploying the whole harness. The open-source agentcontrol library registers rules on a local server via API (a steer rule to reduce guest count over 10, a deny rule for confirmation without payment), and the agent picks them up immediately. Asked to book for 50 guests, the hook agent blocks; the steered agent splits the reservation into two rooms and completes the task. Her rule of thumb: hooks for hard constraints, agentcontrol for soft rules.",
      "Production mapping: Bedrock AgentCore Gateway builds the tool index and does the vector routing for you ('same principle but without infrastructure to manage'); AgentCore Policy enforces rules before tools run; the Strands agent runs inside AgentCore Runtime (any framework, not just Strands) with Gateway routing tool calls to Lambda functions, steering rules living in DynamoDB so a change is live on the next call with no redeploy, plus short/long-term memory and CloudWatch observability. Neo4j AuraDB (free tier) covers the graph."
    ],
    "takeaways": [
      "Stop writing constraints in the system prompt or tool description and expect them to hold — put the rule in a before-tool-call hook in Python where the model cannot escape it, and reserve the prompt for guidance.",
      "Build a small vector index over your tool descriptions and inject only the top-k matches per query; if you have a conversation loop, clear and re-register tools each invocation so history plus tools doesn't quietly rebuild the full 29-tool context.",
      "Route 'how many', 'what is the average', and multi-hop questions to a graph query (Cypher over Neo4j) instead of RAG — let the database do the arithmetic so the answer is computed and verified rather than sampled from three chunks.",
      "Don't let an agent validate its own output in the same loop: add a separate validator and critic (Strands Swarm handles the handoffs) so tool errors surface as failures instead of fabricated success confirmations.",
      "Decide per rule whether you want a block or a steer — a hard stop leaves the user waiting, while a steering rule lets the agent self-correct (split 50 guests across two rooms) and finish the task; keep steering rules in an external store so you can change them without redeploying the agent."
    ],
    "topics": [
      "agents",
      "hallucinations",
      "tool-selection",
      "graphrag",
      "multi-agent",
      "guardrails",
      "token-costs",
      "aws"
    ],
    "tools": [
      "Strands Agents",
      "Strands Swarm",
      "Strands hooks",
      "OpenAI API",
      "Amazon Bedrock",
      "Amazon Bedrock AgentCore",
      "AgentCore Gateway",
      "AgentCore Runtime",
      "AgentCore Policy",
      "Neo4j",
      "Neo4j AuraDB",
      "Cypher",
      "Neo4j SimpleKGPipeline",
      "sentence-transformers",
      "Ollama",
      "agentcontrol",
      "AWS Lambda",
      "DynamoDB",
      "CloudWatch",
      "AWS CDK",
      "Jupyter"
    ],
    "quotes": [
      {
        "text": "Each one is a code change, not a prompt change.",
        "at": "00:11",
        "url": "https://www.youtube.com/watch?v=vJukHCIv7Ck&t=11s"
      },
      {
        "text": "Vector search always returns something even when nothing is truly relevant.",
        "at": "18:51",
        "url": "https://www.youtube.com/watch?v=vJukHCIv7Ck&t=1131s"
      },
      {
        "text": "A rule in the prompt the model read it as a suggestion. A rule in the code the model can not escape it.",
        "at": "36:47",
        "url": "https://www.youtube.com/watch?v=vJukHCIv7Ck&t=2207s"
      },
      {
        "text": "The user thinks it work. You think it work. It didn't not. The agent acts and validate its own output in the same loop.",
        "at": "29:35",
        "url": "https://www.youtube.com/watch?v=vJukHCIv7Ck&t=1775s"
      }
    ],
    "words": 8444
  },
  "summary_url": "/#vJukHCIv7Ck",
  "transcript": {
    "html": "/transcripts/vJukHCIv7Ck.html",
    "txt": "/transcripts/vJukHCIv7Ck.txt",
    "vtt": "/transcripts/vJukHCIv7Ck.vtt"
  }
}