RAG Knowledge Agent
Answer questions strictly from your own documents using vector search, with a guardrail that blocks answers the sources don't support.
What you'll build
A question-answering agent that only speaks from your documents. It retrieves the most relevant passages with vector search, answers from them, and refuses to guess when the documents don't contain the answer — retrieval-augmented generation (RAG) with a hallucination guard.
Trigger: a chat message carrying the question in {{starter.input}}.
The workflow
Before you start
Create a Knowledge collection and upload your documents (PDFs, Markdown, web pages). Zelaxy chunks and embeds them into pgvector automatically. See the Knowledge block for ingestion details.
Build it
Starter — accept the question
Add a Starter with a Chat trigger. The question is {{starter.input}}.
Knowledge — retrieve relevant passages
Add a Knowledge block. Point it at your collection, set the query to {{starter.input}}, and choose a top-K (start with 5). It returns the closest chunks as {{knowledge.results}}, each with its source and a similarity score.
Agent — answer only from the passages
Add an Agent with a strict system prompt:
Answer the question using ONLY the passages below. Quote or paraphrase them and cite each source. If the passages do not contain the answer, reply exactly: "I don't have that in my documents." Do not use outside knowledge.
User message:
Question: {{starter.input}}
Passages:
{{knowledge.results}}Guardrails — block ungrounded answers
Add a Guardrails block after the agent. Enable the hallucination / grounding check so any answer not supported by {{knowledge.results}} is flagged before it reaches the user. On failure, fall back to the "I don't have that" message.
Response — return the grounded answer
Add a Response block returning {{agent.content}}.
Make it yours
- Cite inline. Turn on structured output on the agent (
{ "answer": "string", "sources": ["string"] }) and render the sources list in your UI. - Multi-collection. Add a Router before Knowledge that picks which collection to search based on the question's topic.
- Freshness. Combine with the Research Agent — search your docs first, and only fall back to the web when Knowledge returns nothing.
- Memory. Add a Memory block to keep conversation context across turns for a true chat experience.
Related
Customer Support Agent
Classify inbound support email, draft a grounded reply from your knowledge base, gate urgent cases behind a human, and notify the team in Slack.
Multi-Agent Content Pipeline
Chain a researcher, a writer, and an editor agent so a single topic becomes publish-ready copy through specialized hand-offs.