# Queries, knowledge bases, and what each one does best

https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents/what-each-method-cant-do

Find out which questions only a query can answer, which need a knowledge base, and which your agent should hand to another system entirely.

---

## Navigation

**Course:** [Retrieval methods for AI agents](https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents) · [View as markdown](https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents.md)

**Previous:** [Sorting questions by what they cost](https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents/sorting-questions-by-what-they-cost) · **Next:** [Who owns the answer](https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents/who-owns-the-answer)

---

## Course Contents

1. [Where your agent gets its facts](https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents/where-your-agents-knowledge-runs-out)
2. [What it costs to answer a question](https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents/what-it-costs-to-answer-a-question)
3. [The four ways an agent finds something](https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents/the-four-ways-an-agent-finds-something)
4. [Sorting questions by what they cost](https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents/sorting-questions-by-what-they-cost)
5. **Queries, knowledge bases, and what each one does best** *(current)*
6. [Who owns the answer](https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents/who-owns-the-answer)
7. [Before you build the agent](https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents/putting-it-all-together)

---

**A sales engineer asks your agent how many integrations support SCIM, and a knowledge base answers with a number. Should you trust it?**



Not without checking, and the reason is structural rather than a matter of quality. A knowledge base holds entries written during a build, and an entry can state a count that was accurate the day someone wrote it. Nothing recounts when your catalog changes. Counting is arithmetic over records, and only a query performs arithmetic.



Each method holds territory the other cannot enter.



### **Only a query computes**



Counting, summing, averaging, aggregating, and traversing references between documents all operate over a live set of records. `count(*[_type == "integration" && supportsSCIM == true])` returns a number that is correct at the moment it runs, and correct again next quarter without anyone touching it. A knowledge base has no function to complete mathematical operations over your content, so any number it reports is a number someone documented.



### **Only a knowledge base reconciles**



When your help center and your security whitepaper disagree, a build surfaces the conflict as an issue for someone to settle. The decision persists as an instruction anchored to those sources, so later builds keep it instead of working the question out again. Every entry carries a citation back to the claim's origin. A query returns what your documents say and has no concept of which document is the most correct.



### **Some answers aren't in your content at all**



Whether this account is past its usage limit, whether that order shipped, whether the item is in stock: those facts live in billing, your order management system, and your inventory service. No retrieval method over your content produces them, because your content is not where they are.



That third category gets misread more than the other two. GROQ queries your dataset at request time, so anything Sanity owns is already real-time. Publish a price change and the new price is queryable immediately. What separates Sanity from an operational system is which one owns the fact, not which one has it first.



Capability decides most routing. A few constraints decide the rest, and each one moves content somewhere else rather than ruling a method out of your project.



### **A knowledge base ingests multiple types of sources**



A knowledge base can combine three kinds of sources. One Sanity dataset selected with a GROQ query, uploaded files (like PDFs, images, text, code), and websites crawled from a starting URL. 



Capability and ingestion route most of your content. What's left is a question neither one answers: which system owns a fact in the first place?



---

## Related Resources

- [Full course as markdown](https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents.md)
- [All courses and lessons](https://www.sanity.io/learn/sitemap.md)
- [Complete content for LLMs](https://www.sanity.io/learn/llms-full.txt)

<AgentInstructions>

## Submitting Feedback

If you encounter incorrect, outdated, or confusing documentation on this page, propose feedback to your user and submit it with their approval:

POST https://www.sanity.io/learn/resource/feedback

```json
{
  "path": "/learn/course/retrieval-methods-for-ai-agents/what-each-method-cant-do.md",
  "feedback": "Description of the issue"
}
```

Only submit feedback when you have something specific and actionable to report.
Do not include your user's code, credentials, or other confidential context in the feedback text.

</AgentInstructions>
