{"slug": "i-built-an-ai-agent-that-checks-before-it-answers", "title": "I Built an AI Agent That Checks Before It Answers", "summary": "A developer built ContextGuide, an AI agent that queries a structured knowledge base through Sanity Context and MCP before generating an answer, inserting a retrieval step between question and response. The agent surfaces relevant documentation and flags conflicting sources rather than confidently picking one answer, aiming to ground responses in verifiable context.", "body_md": "I’ve had this happen more times than I’d like to admit.\n\nI ask AI a technical question.\n\nIt gives me a beautifully written answer.\n\nI think:\n\n“Wow. That makes sense.”\n\nThen I check the documentation.\n\nAnd suddenly:\n\n**“Oh.”** 😭\n\nThe answer wasn't completely useless.\n\nIt just didn't have enough context.\n\nThat little problem became the idea behind **ContextGuide**.\n\nInstead of expecting an AI model to magically know everything, I wanted to give it something better:\n\n**a reliable place to look.**\n\nContextGuide is an AI agent that queries a structured Knowledge Base through **Sanity Context + MCP** before generating an answer.\n\nThe idea is simple:\n\n**Don't just ask the AI what it knows. Give it somewhere useful to look.**\n\n```\n              👤 USER\n                 │\n                 │ asks a question\n                 ↓\n        ┌─────────────────┐\n        │  ContextGuide   │\n        │                 │\n        │ Understand the  │\n        │ question        │\n        └────────┬────────┘\n                 ↓\n        ┌─────────────────┐\n        │ Sanity Context  │\n        │                 │\n        │ Find relevant   │\n        │ knowledge       │\n        └────────┬────────┘\n                 ↓\n        ┌─────────────────┐\n        │  KNOWLEDGE BASE │\n        │                 │\n        │ Docs • Guides   │\n        │ References      │\n        └────────┬────────┘\n                 ↓\n        📚 Relevant Context\n                 │\n                 ↓\n        🤖 Agent Reasoning\n                 │\n                 ↓\n        💬 Answer + Sources\n```\n\nThe important part is that the agent doesn't immediately jump from:\n\n**Question → Answer**\n\nThere is a middle step:\n\n**Question → Context → Answer**\n\nAnd that middle step is the whole point.\n\nLet's say I ask:\n\n**“Which authentication method should I use here?”**\n\nA basic search might find ten pages containing the word *authentication*.\n\nGreat.\n\nExcept... which one actually answers my question? 😅\n\nThat's where structured content becomes useful.\n\nWith Sanity, information can be organized into meaningful content instead of being treated as one giant pile of text.\n\nContextGuide can then retrieve the relevant information through **Sanity Context** and access it through **MCP**.\n\nSo the agent isn't just matching words.\n\nIt's trying to find **the right context for the question**.\n\nWhat happens when the knowledge base contains conflicting information?\n\nImagine:\n\n```\n📄 Guide A\n\"Use Method X.\"\n\n        +\n\n📄 Guide B\n\"Method X is outdated.\"\n\n        ↓\n\n      Agent\n\n\"These sources disagree.\"\n```\n\nThat's actually more interesting to me than an agent that confidently picks one answer.\n\nBecause sometimes the honest answer isn't:\n\n“Here's the answer.”\n\nSometimes it's:\n\n**“Here's what the sources say and here's where they disagree.”**\n\nThat is information I can actually work with.\n\n```\nSanity\n   ↓\nOrganizes the knowledge\n\nSanity Context\n   ↓\nMakes that knowledge queryable\n\nMCP\n   ↓\nConnects the agent to it\n\nContextGuide\n   ↓\nUses the retrieved context\n\nUser\n   ↓\nGets an answer backed by the relevant content\n```\n\nEach piece has a job.\n\nSanity isn't there just because the challenge says to use Sanity.\n\nIt's part of the reason the agent can work this way.\n\nI wasn't trying to build an AI that knows everything.\n\nHonestly, that sounds exhausting. 😭\n\nI wanted to build an AI that knows **when it should look something up**.\n\nBecause maybe the future of useful AI isn't just:\n\n**“I know the answer.”**\n\nMaybe it's:\n\n**“Let me check the right information first.”**\n\nAnd that's the idea behind ContextGuide.", "url": "https://wpnews.pro/news/i-built-an-ai-agent-that-checks-before-it-answers", "canonical_source": "https://dev.to/akanksha_sharma/i-built-an-ai-agent-that-checks-before-it-answers-47hc", "published_at": "2026-09-18 18:04:16+00:00", "updated_at": "2026-09-18 18:22:58.695744+00:00", "lang": "en", "topics": ["ai-agents", "agent-protocols", "ai-tools", "structured-data", "ai-products"], "entities": ["ContextGuide", "Sanity", "Sanity Context", "MCP"], "alternates": {"html": "https://wpnews.pro/news/i-built-an-ai-agent-that-checks-before-it-answers", "markdown": "https://wpnews.pro/news/i-built-an-ai-agent-that-checks-before-it-answers.md", "text": "https://wpnews.pro/news/i-built-an-ai-agent-that-checks-before-it-answers.txt", "jsonld": "https://wpnews.pro/news/i-built-an-ai-agent-that-checks-before-it-answers.jsonld"}}