Build a Retrieval (RAG) Tool an Agent Can Query
Design a retrieval tool that returns grounded, citable chunks so an agent answers from your data instead of guessing.
Give an agent a clean retrieval interface — query in, ranked passages with sources out — that minimizes hallucination.
At a glance
Access
Free prompt
Open to copy — no account or payment needed.
Prompt objective
Give an agent a clean retrieval interface — query in, ranked passages with sources out — that minimizes hallucination.
Real use case
A support agent needs to answer from a 4,000-page knowledge base. Raw vector search returns noisy chunks, so answers are inconsistent and uncited.
Customize these fields first
Replace the placeholders with your own context before you run the prompt. That usually improves the first output more than adding more instructions later.
Prompt
Act as a RAG/retrieval engineer. Design a retrieval tool that an AI agent will call to ground its answers in our knowledge base. Knowledge base: [WHAT IT CONTAINS, SIZE, UPDATE FREQUENCY] Typical questions: [EXAMPLES] Where answers will be used: [SUPPORT, INTERNAL, PUBLIC] Produce: 1. Chunking strategy: how to split documents, target chunk size, and metadata to attach (source, section, date). 2. Index choice and the retrieve() tool signature the agent calls (query, filters, top_k) and the exact return shape (passage text, source id, score). 3. Ranking/re-ranking approach to push the most relevant passages to the top. 4. The grounding contract for the agent: answer only from retrieved passages, cite each claim by source id, and say "not in the knowledge base" when coverage is missing. 5. Freshness handling for updated/removed documents. 6. 3 evaluation questions with the ideal cited answer to test the pipeline. Optimize for precision and citability over recall.
Open directly in an AI — the text is pre-filled:
How to use this prompt
- 1Replace the key placeholders first: WHAT IT CONTAINS, SIZE, UPDATE FREQUENCY, EXAMPLES, SUPPORT, INTERNAL, PUBLIC.
- 2Replace any bracketed placeholders like [this] with your own context.
- 3Add extra background information when you want more tailored results.
- 4Combine multiple prompts in one conversation when you need a richer output.
- 5Save your best-performing prompts so they are easy to reuse later.
Next best step
Open the guide first, then branch only if you still need more.
A guide for technical builders choosing between prompts, coding workflows, and agent-based implementation.
If this prompt is close but not quite right, generate variants next. If the job is recurring, move into the course library after the guide.
Related prompts
View allDesign an MCP Server to Expose Internal Tools to an Agent
Plan a Model Context Protocol server that safely exposes your internal data and actions as tools an agent can call.
Best for
Get a concrete MCP server design — tools, resources, auth, and limits — so agents in Claude, Claude Code, or other MCP clients can use your systems.
Write Tool Descriptions a Model Will Actually Use Correctly
Rewrite ambiguous tool/function definitions so an agent reliably selects the right tool with the right arguments.
Best for
Reduce wrong-tool and bad-argument errors by making each tool's name, description, and parameter docs unambiguous to the model.
Explore other prompt categories
Move sideways into adjacent libraries when the current category is not the full answer.
Every prompt here is free. The course teaches the thinking behind them.
Copy as many prompts as you like. When you want to move from single prompts to a repeatable AI workflow, Learn AI in 30 Days walks through it, one day at a time.
Buy the course once ($15/$20 by length), or go all-access for $10/mo with a verifiable certificate.