CoursesRetrieval methods for AI agentsBefore you build the agent
Retrieval methods for AI agents

Before you build the agent

Plan where each of your agent's answers should come from before you build it, so the agent isn't choosing its own sources while a customer waits.
Log in to mark your progress for each Lesson and Task

Which question in your product costs the most to get wrong?

Start there, because deciding where an answer comes from pays off fastest on the questions that carry consequences.

Retrieval is the handoff between what a model knows and what your business knows, and the method you choose decides what your agent can answer and how consistently it answers.

Answers that already exist as structured content belong in a live query. GROQ mode narrows with a filter, ranks with score(), and weights with boost(), all in one query against content that is current the moment the question arrives. Counting, summing, and traversing references belong here too, because no other method computes.

Answers scattered across prose that nobody has settled belong in a knowledge base. A build gathers them, surfaces the contradictions for a person to resolve, and writes entries with citations, so your agent retrieves a reviewed conclusion instead of reaching a fresh one while a customer waits.

Three properties tell you which is which: gathering, reconciling, and judgment. A fourth question tells you how much the answer matters: is there a single right answer, and what does getting it wrong cost?

Some answers belong to neither method. Per-account state, live inventory, and transactional status live in the systems that own them, and your agent's job is to route to those systems rather than guess from content that looks close enough.

The first thing to build is not an agent. Write the ownership table for your own content: every kind of question your users ask, with exactly one owner each. The rows you hesitate on are the ones worth settling now, while the cost of being wrong is a conversation rather than a customer.

Check out the following courses and docs to start building your own agent with structured content, grounded in facts, using knowledge bases.

Mark lesson as complete
You have 1 uncompleted task in this lesson
0 of 1