# Who owns the answer

https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents/who-owns-the-answer

Scope what your agent can reach with Sanity Context, and recognize the answers that shouldn't come from your content at all.

---

## 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:** [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) · **Next:** [Before you build the agent](https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents/putting-it-all-together)

---

## 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](https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents/what-each-method-cant-do)
6. **Who owns the answer** *(current)*
7. [Before you build the agent](https://www.sanity.io/learn/course/retrieval-methods-for-ai-agents/putting-it-all-together)

---

**A customer asks your agent whether their account is past its usage limit, and the agent answers from your pricing content. What went wrong?**



The agent answered a question about one account using a document that describes a plan. The plan's limit is 50,000 events, which is true, published, and correctly retrieved. Whether this particular customer has used 51,000 of them is a fact only your billing system holds. The answer was assembled with complete confidence from the wrong owner.



### **Nothing routes the question for you**



Nothing in the retrieval layer prevents that. There is no built-in router. Every backend you connect contributes its tools to one flat list, and the model chooses by matching tool names and descriptions against the conversation. Sanity Context's tools are deliberately generic. `groq_query`, `schema_explorer`, and `initial_context` describe mechanisms rather than domains, so a model choosing between them and a billing API's tools has very little to go on.



### **One owner for every kind of data**



You are the router. An ownership table makes the split visible, with exactly one owner for each kind of data your agent could be asked about.



- **Catalog, articles, help content, and marketing copy.** Sanity owns them, because they are structured, editorially managed, and queryable.

- **Live inventory, order status, and shipping.** Your commerce platform or order management system owns them, because they change second by second.

- **Payments and refunds.** Your billing system owns them as the system of record, and the operations have side effects.

- **Support ticket history.** Your helpdesk owns it, because it owns the conversation.

- **Entitlements and current usage.** Your billing or entitlement service owns them, because they are per-account state.


Sanity owns your content: the product, the plan, the policy, and every word you have published about them. Operational systems own state: what this customer has used, where that order is, how many units are left. Most routing problems answer themselves once the split is clean, and the table becomes the routing table in your system prompt when you build.



### **How to keep each answer with its owner**



Four ways to enforce the split:



1. **A routing table in the system prompt.** Name each data type and the tool that owns it. This isn’t complex, and it handles the ordinary cases.

2. **Structural scoping.** A `groqFilter` on the Context document keeps out-of-scope content from being returned at all, and an instruction stating what the dataset does not contain ("live stock is not stored here, use the inventory tool") closes the gap from the other side. The scoping fails safe, which the prompt alone does not.

3. **Reshaping the tool set.** Subset and re-describe the generic tools before handing them to the model, so the description carries the domain and the boundary.

4. **Architectural change.** Past a certain complexity, a cheap classification call that picks a domain first, or a supervisor that delegates to sub-agents holding only the relevant tools, scales better than one agent holding every tool.


```typescript
const tools = {
  ...commerceTools,
  query_content: {
    ...sanityTools.groq_query,
    description:
      'Query the CONTENT catalog (products, articles, help docs) in Sanity. ' +
      'Use for descriptions, specs, copy, and canonical IDs, NOT live stock or orders.',
  },
}
```

### **A filter blocks what an instruction only discourages**



Scoping is the difference between an agent that is asked not to reach something and an agent that cannot. A `groqFilter` is an access boundary enforced at the endpoint, so excluded content never reaches the model at all. Unreleased work is the clearest case. A plan tier launching next quarter, a feature still in staging, an integration under NDA: all of it sits in your dataset, and none of it should reach a customer-facing agent. A filter like `_type == "feature" && status == "ga"` keeps it out structurally rather than asking the model not to mention it. 



Sanity Context separates what an agent can reach from how it behaves. Scope is the filter. Behavior is the instructions, and they live in Sanity rather than in your agent code, so changing how your agent uses your content takes no deploy and no additional dev work. 



Knowledge bases add a review step that isn't possible at query time. A build surfaces contradictions as issues before anything reaches production, a person settles them, and the decision persists as an instruction anchored to its sources. Every entry cites where its claim came from. Query time retrieval still involves judgment about which source to believe. The judgment happens at answer time instead, once per question, with no one to validate.



Composing across owners is how a working agent answers a question like the one that opened this lesson. Resolve the canonical product and its editorial detail from Sanity, hand the SKU to the commerce API for live stock, and answer from both. Because you own the split, you decide what your agent trusts for which class of fact, and no vendor default decides it for you.



> **Question:** A customer asks whether their account is past its usage limit. Which system should answer?
>
> 1. The billing or entitlement service that tracks consumption **[correct]**
> 2. A GROQ query against your plan documents
> 3. A knowledge base entry describing plan limits
> 4. The system prompt, if the limits are listed there

---

## 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/who-owns-the-answer.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>
