RAG Agent
RAG Agent
The RAG Agent is an advanced orchestration component designed specifically for search and answer tasks based on external knowledge. It combines the power of a language model with direct access to document databases to answer questions in an intelligent and verifiable way.
Unlike standard flows, this agent implements a reasoning cycle that includes fragment retrieval, response generation, and an optional quality control phase to ensure the output is coherent and free of hallucinations.
Main Use Cases
Use the RAG Agent to develop solutions that require:
- Knowledge Base Queries: To answer questions based on specific documents such as manuals or internal policies.
- High-Precision Systems: In environments where fabricated information must be avoided through hallucination checks.
- Hybrid Search: When private documents need to be combined with web search if local information is not found.
- Process Automation: To generate structured responses (JSON) that feed into other automatic systems.
Fundamental Configuration
These parameters form the basis of the RAG Agent's behavior and identity.
| Parameter | Technical Description | Purpose in the Flow |
|---|---|---|
User Request | The direct user query or question that triggers execution. | Defines the agent’s search and processing objective. |
User Prompt | Custom template (e.g., {input}) to format the user’s input. | Guides how the agent should interpret and process the initial request. |
Model | Connection to the Language Model (LLM) that will act as the reasoning engine. | Responsible for processing the question along with the retrieved documents. |
Retrievers | List of search mechanisms to find relevant documents. | Act as the external source of truth from which information is extracted. |
Tools | Additional tools the agent can invoke during execution. | Expands the agent’s capabilities by allowing it to interact with other services. |
Use Memory | Activates the memory system to maintain context between interactions. | Allows for coherent dialogues where the agent remembers previous questions. |
Advanced Features (Plug in advanced features)
By configuring advanced options, layers of control and reliability are enabled over the generation process.
Quality Control: Response Verification
Enable Document Relevance Grading: Activates scoring and relevance filtering for each retrieved document before generating the response.Enable Hallucination Check: Checks that the response does not contain fabricated information that is not supported by the source documents.Enable Answer Quality Check: Enables a verification to ensure that the final response correctly addresses the user’s original question.
Resilience and Output
Enable Web Search Fallback: If no relevant documents are found in the retrievers, it allows the agent to search the web as a last resort.JSON Structured Output: Forces the agent to format the final response as a valid JSON object.Stream: Sends the response in real-time (streaming) as it is generated.Vector DB Metadata Schema: Metadata schema that allows optimizing and accelerating searches in the vector database.
Component Outputs
Response: The final message containing the response generated and validated by the agent.Agent: ACompiledGraphobject representing the agent ready to be executed.Tool: An object that allows this agent to be used as a tool by other components.
Tips and Best Practices
- Optimize metadata: A good schema in the
Vector DB Metadata Schemadrastically improves search relevance. - Prioritize security: Enabling
Answer Quality CheckandHallucination Checkreduces errors and improves user trust. - Resource management: If the flow is short, disable
Use Memoryto save resources.
You can watch a video showing the power of the RAG Agent here.