cd /news/ai-agents/i-built-an-ai-agent-that-checks-befo… Β· home β€Ί topics β€Ί ai-agents β€Ί article
[ARTICLE Β· art-133992] src=dev.to β†— pub= topic=ai-agents verified=true sentiment=↑ positive

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.

by read3 min views1 publishedSep 18, 2026

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.

── more in #ai-agents 4 stories Β· sorted by recency
── more on @contextguide 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/i-built-an-ai-agent-…] indexed:0 read:3min 2026-09-18 Β· β€”