RAG Agent
The RAG Agent is a component that lets your automation system find the right documents, ask a language model for help, and give you a clear answer. Think of it as a smart assistant that reads the right files and then writes the answer for you.
How it Works
When you give the RAG Agent a question, it does three main things:
- Find the right documents – It uses the Retrievers you choose to search your data store and pull the most relevant files.
- Ask the language model – It sends the question and the retrieved documents to the Model you selected. The model can also use any Tools you provide to do extra work (for example, calling an API or running a calculation).
- Return a polished answer – The agent can format the answer as plain text, JSON, or even check the answer for quality, relevance, or hallucinations. If no documents are found, it can optionally search the web for you.
All of this happens inside the dashboard, so you don’t need to write code. Just set the inputs, run the component, and use the outputs in your workflow.
Inputs
- Model: The language model that will generate the answer (e.g., GPT‑4, Claude, etc.).
- Retrievers: A list of retrievers that will search your documents for relevant information.
- Tools: Optional tools that the agent can call while answering (e.g., a calculator, a database query tool, etc.).
- JSON Structured Output: If checked, the agent will format its final answer as a JSON object.
- Enable Answer Quality Check: If checked, the agent will verify that its answer actually addresses the user’s question.
- Enable Document Relevance Grading: If checked, each retrieved document will be scored for relevance and filtered accordingly.
- Enable Hallucination Check: If checked, the agent will compare its answer against the retrieved documents to spot made‑up facts.
- Enable Web Search Fallback: If checked, the agent will search the web when it can’t find enough relevant documents locally.
- Agent Description: A short description that helps the system understand what the agent does when it’s used as a tool or part of a larger workflow.
- Agent Name: The name of the executor that will run the agent.
- Input: The raw input that the agent receives (usually the user’s question).
- Vector DB Metadata Schema: A schema that tells the vector database how to store and search metadata for faster results.
- Adicional Instructions: Extra instructions you want the agent to follow to improve its responses.
- Use Memory: If checked, the agent will remember past interactions to keep context.
- Stream: If checked, the agent will stream its answer back to you as it is generated.
- User Prompt: A custom prompt that can guide the agent’s behavior.
- User request: The actual question or search query from the user.
- Tool Name: The name that will appear to the agent when it selects a tool to use.
- Tool Description: A detailed description of what the tool does, helping the agent decide when to use it.
- Tools arguments metadata: Metadata that defines the arguments each tool expects.
Outputs
- Agent: A compiled graph that you can run to start the agent.
- Response: The final answer from the agent, formatted as a message.
- Tool: A toolkit representation that can be passed to other components that need to call the agent’s tools.
Usage Example
- Goal: A sales manager wants to know the total revenue for the last quarter.
- Setup:
- Choose a powerful model (e.g., GPT‑4).
- Add a retriever that searches your sales database.
- Enable Enable Answer Quality Check to make sure the answer is correct.
- Enable JSON Structured Output so the answer can be parsed automatically.
- Run: The manager enters the question “What was the total revenue in Q3 2023?”
- Result: The agent pulls the relevant sales reports, asks the model to calculate the sum, checks the answer, and returns a JSON object like
{ "totalRevenue": 1250000 }
.
You can then feed that JSON into a chart component to display the revenue graph.
Related Components
- LanggraphBaseRAGAgent – The base class that provides core RAG functionality.
- Document Retriever – A component that fetches documents from your data store.
- Tool Executor – Lets you run custom tools (APIs, scripts, etc.) from within the agent.
- Memory Store – Stores conversation history for context‑aware responses.
Tips and Best Practices
- Pick the right model – A larger model gives better answers but costs more.
- Use relevant retrievers – Narrow the search to the most useful data sources.
- Enable quality checks – They help catch mistakes before the answer reaches the user.
- Format as JSON when you need structured data – Makes downstream processing easier.
- Keep memory off for short tasks – Saves resources if you don’t need context.
Security Considerations
- Data privacy – All document searches happen inside your environment unless you enable web search.
- API keys – If you use external tools or models, store keys securely in the dashboard’s credential manager.
- Model safety – Enable hallucination checks if you’re handling sensitive or regulated information.