Building an AI support agent with RAG: architecture, evaluation and pitfalls
How to build a retrieval-augmented (RAG) AI support agent that answers from your knowledge base: architecture, chunking, evaluation, guardrails, handover and cost.
By INTELLIA AI & Data Team · Reviewed by INTELLIA Engineering Team
Published
Last updated
3 min read
Short answer
A RAG support agent answers customer or staff questions by first retrieving relevant passages from your own knowledge base and then asking a language model to write an answer using only those passages, with citations. Building one well requires clean source content, good chunking and retrieval, an evaluation set of real questions, guardrails, human handover and cost monitoring.
How to build a RAG support agent: step by step
- 1
Collect and clean knowledge sources
Gather help articles, policies, product data and resolved tickets; remove outdated and duplicate content.
- 2
Chunk and index
Split documents into meaningful sections with metadata and index them for keyword and vector search.
- 3
Build an evaluation set
Collect 100 to 300 real questions with expert-approved answers and source passages.
- 4
Implement retrieval and generation
Retrieve top passages, re-rank them, and prompt the model to answer only from them with citations.
- 5
Add guardrails and handover
Detect low confidence, sensitive topics and requests for a human, and hand over with context.
- 6
Monitor and improve
Score answers continuously, review failures weekly and update content and prompts.
What a RAG agent is, and is not
A RAG agent is a search engine and a writer working together. The search step finds the passages in your knowledge base most relevant to the question; the writing step turns those passages into a clear answer. It is not a model that "knows" your business. If the right passage is not retrieved, the answer will be wrong or missing, which is why most of the work lies in content and retrieval rather than in the model.
Reference architecture
| Layer | Responsibility | Typical components |
|---|---|---|
| Channels | Where questions arrive | Website chat, WhatsApp, helpdesk, intranet |
| Orchestrator | Conversation state, routing, tools | Application service (Python or Node.js) |
| Retrieval | Find relevant passages | Keyword index, vector index, re-ranker |
| Generation | Write grounded answers | Hosted or self-hosted language model |
| Guardrails | Safety, PII, policy | Classifiers, redaction, rules |
| Observability | Quality, latency, cost | Logs, evaluation runs, dashboards |
Step 1: Fix the knowledge base first
The most common reason for poor answers is poor source material: outdated articles, contradictions between documents, and answers that exist only in agents' heads. Before writing code:
- Remove or archive outdated content.
- Resolve contradictions and assign an owner to each article.
- Turn frequent ticket resolutions into articles.
- Add metadata: product, region, audience, effective date.
Step 2: Chunking and retrieval
Split documents along their natural structure, such as headings and numbered steps, rather than fixed character counts. Keep chunks small enough to be specific but large enough to make sense alone, and store the document title and section path with each chunk.
Use hybrid retrieval: keyword search catches exact terms like product codes; vector search catches paraphrases. A re-ranking step then orders the combined results by relevance. Filter by metadata so a customer in the UAE does not receive a Pakistan-only policy.
Step 3: Evaluation before optimization
Create an evaluation set of real questions, drawn from tickets and chat logs, each with an approved answer and the source passage. Score every change against it:
- Retrieval recall: did the right passage appear in the top results?
- Groundedness: is every claim in the answer supported by a retrieved passage?
- Correctness: does the answer match the approved one?
- Helpfulness and tone: reviewed by experts on a sample.
Without this set, teams tune prompts by intuition and regress without noticing.
Step 4: Prompting for grounded answers
Good prompts for support agents instruct the model to answer only from the provided passages, cite them, say clearly when the information is not available, keep answers short and follow a defined tone. Store prompts in version control and evaluate every change before release.
Step 5: Guardrails and handover
- Low confidence: if retrieval scores are weak, do not guess; offer a human.
- Sensitive topics: complaints, legal threats, medical or financial advice go to people.
- Personal data: mask it before sending to external models where policy requires.
- Explicit requests: "talk to a person" always works.
When handing over, pass the conversation summary and retrieved sources to the agent so the customer does not repeat themselves. In CX Hub, the summary appears in the ticket.
Step 6: Tools, not just answers
Many support questions need live data: "Where is my order?", "What is my balance?" Tool calling lets the agent call your APIs with the customer's verified identity. Keep tools narrow (look up one order, not query the database), log every call, and require confirmation for actions that change data.
Step 7: Cost and latency
Track cost per resolved conversation. Practical levers: use smaller models for classification and routing, cache answers to frequent questions, limit retrieved context to what is needed, and stream responses so users see progress immediately.
RAG vs fine-tuning vs rules
| Approach | Best for | Weakness |
|---|---|---|
| Rules and menus | A handful of fixed flows | Breaks on unexpected phrasing |
| RAG | Answers from changing documents | Depends on content quality |
| Fine-tuning | Consistent tone and format | Expensive to keep current |
| RAG + tools | Answers plus live account data | More integration and security work |
Pitfalls we see often
- Launching to all customers without a pilot group.
- Measuring deflection without measuring satisfaction.
- No owner for the knowledge base after launch.
- Treating handover as failure instead of a designed path.
Where to start
Pick one channel and one topic area, build the evaluation set, and pilot with internal agents first using AI-suggested replies. Our AI and machine learning service runs this as a four-to-eight-week pilot, SCRIBA applies the same retrieval to internal documents, and LOOMX brings the agent to WhatsApp.
Frequently asked questions
What does RAG stand for?
Is RAG better than fine-tuning for customer support?
How do you stop the AI from making things up?
How many documents do you need?
Can a RAG agent take actions like checking order status?
About the author
INTELLIA AI & Data Team
AI, machine learning and analytics
The team responsible for INTELLIA's conversational AI, retrieval-augmented generation, analytics dashboards and data pipelines.
Keep reading
All insightsGuide
WhatsApp Business API: pricing, setup and what to automate first
A practical guide to the WhatsApp Business Platform: how Meta pricing works, setup steps, Cloud API vs On-Premises, template rules and what to automate first.
· 3 min read
Article
Contact-center metrics that matter (and the ones that mislead)
Which contact-center KPIs to track: service level, abandonment, handle time, first contact resolution, occupancy and CSAT, with formulas, pitfalls and dashboard advice.
· 2 min read
Guide
A data analytics roadmap for SMEs: from spreadsheets to decisions
A five-stage data analytics roadmap for small and mid-sized companies: agree metrics, connect sources, build a warehouse, ship dashboards, then add forecasting and AI.
· 2 min read
Have a project in mind?
Tell us what you are trying to achieve. A solution architect will reply within one business day with next steps — not a sales script.

