Tools-First, Then RAG
also known as check-the-knowledge-shape, anti-naive-RAG-first
Before you build RAG (retrieval-augmented generation), check whether the knowledge really needs search at all. Data that lives in a database or behind an API is best reached with a direct query or API call. A small, stable set of text can just be pasted into the prompt. Only large piles of unstructured text actually need search over embeddings. Reaching for RAG by default wastes effort and gives fuzzy answers in cases where a direct query would have been exact.
Methodology process overview
Intent. Check what shape your knowledge is in before you choose search, then pick the simplest way to reach each source.
When to apply. Use this when you start any agent or app that answers from a body of knowledge: a support bot, an internal Q&A tool, a docs helper, a policy assistant. Run it before you commit to a vector store. Don't apply it if you already know the knowledge is large and unstructured, because then RAG is the right choice from the start.
Inputs
- Knowledge inventory — A list of every knowledge source the agent has to reach: databases, APIs, document stores, internal wikis, web pages.
- Per-source schema or sample — For each source: how it is structured (tables, endpoints, fields), how big it is, how often it changes, and a few sample records.
- User query distribution — A sample of the questions real users ask, not the ones the team imagines they ask.
Outputs
- Access-mechanism assignment per source — For each source: how the agent will reach it (direct call, pasted-in text, search, or a mix) and why.
- Tool catalogue — The set of direct calls (SQL, API, search) the agent uses to reach structured sources.
- RAG corpus boundary — The leftover unstructured text, kept as small as possible, that will go through search.
Steps (6)
Inventory the knowledge
List every knowledge source the agent has to reach. For each one, note how it is structured, how big it is, and how often it changes. Don't move on until every source is on the list.
Sort each source by how you reach it
A database or typed API becomes a direct call. A small, stable set of text (under about 5k tokens) gets pasted into the prompt or loaded on demand. A large, unstructured pile of text is a candidate for search. A mixed source gets split apart.
Build the tools first
For every structured source, write a direct call: a SQL helper, an API client, or a search endpoint. The agent calls these straight away, with no embeddings involved.
usesTool Use
Paste in the small sets of text
Put small, stable sets of text straight into the prompt or a loaded document. There is no search round-trip and nothing gets lost.
Build RAG only for what's left
Whatever didn't fit the earlier steps — large, unstructured text — goes through search. By now the body of text is small and well-defined, so testing the search is easy to scope.
Measure correctness end to end
On your test set, compare the answers from direct calls against the answers from search for the same questions. If search wins for a question that has a structured source behind it, fix the tool rather than tuning the search.
Framework-specific instructions
Pick a framework and generate a framework-targeted rewrite of this methodology's steps.
Choose framework
AI-generated for Agent Development Kit (ADK) (Google) — verify against official docs.
Principles
- The shape of the knowledge decides how you reach it. Pick the method that fits.
- Direct calls return exact answers; search returns rough passages. Prefer exact answers when the source allows it.
- RAG is the leftover option, not the default.
- If search beats a direct call, the tool is wrong, not the rule.
Known failure modes (1)
Related patterns (2)
Related compositions (1)
Related methodologies (1)
Sources (3)
AI Engineering: Building Applications with Foundation Models (Chip Huyen, O'Reilly, 2024, ISBN 9781098166298)
Ch 6 'RAG and Agents' — RAG / RAG Architecture / Retrieval Algorithms / Retrieval Optimization / RAG Beyond Texts; Agents / Agent Overview / Tools / Planning / Agent Failure Modes and Evaluation / Memory “RAG ... RAG Architecture ... Retrieval Algorithms ... Retrieval Optimization ... RAG Beyond Texts ... Agents ... Agent Overview ... Tools ... Planning ... Agent Failure Modes and Evaluation ... Memory”
The API-First Alternative to RAG for Structured Data (DreamFactory)
“When it comes to integrating AI with structured data, traditional Retrieval-Augmented Generation (RAG) systems often fall short ... While RAG is effective for retrieving unstructured text, it adds unnecessary complications and risks when u…”
RAG Gone Wrong: The 7 Most Common Mistakes (and How to Avoid Them) — kapa.ai
“Most teams build their RAG pipelines like a weekend hackathon project instead of treating them as a system engineering problem ... the most technical and experienced teams I have worked with actually obsess over fundamentals, such as data…”
Provenance
- Added to catalog:
- Last updated:
- Verification status: verified