What is Agentic RAG?

Agentic RAG (Retrieval-Augmented Generation) takes traditional RAG to the next level by incorporating intelligent agent capabilities:

  • Planning: Breaking complex queries into sub-questions for comprehensive answers
  • Evaluation: Verifying results against source documents for accuracy
  • Multi-step reasoning: Performing multiple retrieval and reasoning steps to build deeper understanding
  • Self-correction: Revising approaches based on intermediate results for better outcomes

How Agentset Improves RAG

Traditional RAG systems simply retrieve relevant documents and generate answers based on those documents. Agentset’s Agentic RAG approach takes this further:

  1. Query Planning: The agent analyzes the user query and determines what information is needed
  2. Strategic Retrieval: Instead of a single retrieval step, the agent can make multiple targeted retrievals
  3. Answer Synthesis: The agent combines information from multiple sources to create a comprehensive answer
  4. Citation Generation: Sources are accurately cited so users can verify information
  5. Self-Verification: The agent checks its answer against source documents for accuracy

Benefits of Agentic RAG

More Accurate Answers

Multi-step reasoning leads to more precise and accurate responses

Handle Complex Queries

Break down complex questions that simple RAG systems can’t handle

Transparent Reasoning

Follow the agent’s reasoning process for better explainability

Source Verification

Every answer is verified against source documents

Example: Agentic RAG vs. Traditional RAG

Using Agentic RAG

Agentset’s agentic capabilities are built into the chat functionality. When having a conversation with your documents:

const response = await agentset.chat({
  namespaceId: namespace.id,
  messages: [
    { role: "user", content: "How did our Q1 sales in Europe compare to Q4 last year?" }
  ],
  options: {
    // Enable detailed reasoning steps in response
    includeReasoningSteps: true,
  }
});

// Access the reasoning steps
console.log(response.reasoningSteps);

Customizing Agentic Behavior

You can customize the agentic RAG approach when creating a namespace or during chat:

// Configure when creating a namespace
const namespace = await agentset.namespaces.create({
  name: "Financial Reports",
  description: "Contains financial reports and analysis",
  options: {
    // Configure retrieval behavior
    retrieval: {
      // Number of documents to retrieve in each step
      docsPerRetrieval: 5,
      // Maximum number of retrieval steps
      maxRetrievalSteps: 3,
    },
    // Configure reasoning behavior
    reasoning: {
      // Whether to enable multi-step reasoning
      enableMultiStep: true,
      // Whether to verify answers against sources
      verifyAnswers: true,
    }
  }
});

// Or configure during chat
const response = await agentset.chat({
  namespaceId: namespace.id,
  messages: [{ role: "user", content: "Analyze our Q1 performance" }],
  options: {
    agentic: {
      // Whether to enable agentic RAG features
      enabled: true,
      // Maximum time to spend on deep research
      maxProcessingTime: 60, // seconds
    }
  }
});