I Built an AI Agent That Checks Before It Answers 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. I’ve had this happen more times than I’d like to admit. I ask AI a technical question. It gives me a beautifully written answer. I think: “Wow. That makes sense.” Then I check the documentation. And suddenly: “Oh.” 😭 The answer wasn't completely useless. It just didn't have enough context. That little problem became the idea behind ContextGuide . Instead of expecting an AI model to magically know everything, I wanted to give it something better: a reliable place to look. ContextGuide is an AI agent that queries a structured Knowledge Base through Sanity Context + MCP before generating an answer. The idea is simple: Don't just ask the AI what it knows. Give it somewhere useful to look. 👤 USER │ │ asks a question ↓ ┌─────────────────┐ │ ContextGuide │ │ │ │ Understand the │ │ question │ └────────┬────────┘ ↓ ┌─────────────────┐ │ Sanity Context │ │ │ │ Find relevant │ │ knowledge │ └────────┬────────┘ ↓ ┌─────────────────┐ │ KNOWLEDGE BASE │ │ │ │ Docs • Guides │ │ References │ └────────┬────────┘ ↓ 📚 Relevant Context │ ↓ 🤖 Agent Reasoning │ ↓ 💬 Answer + Sources The important part is that the agent doesn't immediately jump from: Question → Answer There is a middle step: Question → Context → Answer And that middle step is the whole point. Let's say I ask: “Which authentication method should I use here?” A basic search might find ten pages containing the word authentication . Great. Except... which one actually answers my question? 😅 That's where structured content becomes useful. With Sanity, information can be organized into meaningful content instead of being treated as one giant pile of text. ContextGuide can then retrieve the relevant information through Sanity Context and access it through MCP . So the agent isn't just matching words. It's trying to find the right context for the question . What happens when the knowledge base contains conflicting information? Imagine: 📄 Guide A "Use Method X." + 📄 Guide B "Method X is outdated." ↓ Agent "These sources disagree." That's actually more interesting to me than an agent that confidently picks one answer. Because sometimes the honest answer isn't: “Here's the answer.” Sometimes it's: “Here's what the sources say and here's where they disagree.” That is information I can actually work with. Sanity ↓ Organizes the knowledge Sanity Context ↓ Makes that knowledge queryable MCP ↓ Connects the agent to it ContextGuide ↓ Uses the retrieved context User ↓ Gets an answer backed by the relevant content Each piece has a job. Sanity isn't there just because the challenge says to use Sanity. It's part of the reason the agent can work this way. I wasn't trying to build an AI that knows everything. Honestly, that sounds exhausting. 😭 I wanted to build an AI that knows when it should look something up . Because maybe the future of useful AI isn't just: “I know the answer.” Maybe it's: “Let me check the right information first.” And that's the idea behind ContextGuide.