📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials AI Agents and Automation Agentic RAG

Agentic RAG

5 min read Quiz at the end
Agentic RAG lets agents decide when to retrieve, what to search, and how to combine multiple sources.

Agentic RAG

Agentic RAG goes beyond simple retrieval — the agent decides what to search, when to search again, and how to synthesise results from multiple sources.

from langchain.agents import create_tool_calling_agent, AgentExecutor
from langchain_community.vectorstores import Chroma
from langchain_core.tools import tool
from langchain_openai import OpenAIEmbeddings

# Build vector store
vectorstore = Chroma.from_documents(docs, OpenAIEmbeddings())
retriever   = vectorstore.as_retriever(search_kwargs={"k":5})

@tool
def search_knowledge_base(query: str) -> str:
    """Search internal knowledge base for relevant information."""
    docs = retriever.invoke(query)
    return "
---
".join(d.page_content for d in docs)

@tool
def search_web(query: str) -> str:
    """Search the web for current information not in knowledge base."""
    return web_search(query)

@tool
def check_date_relevance(topic: str) -> str:
    """Check if information about a topic might be outdated."""
    return llm.invoke(f"Is info about {topic} likely outdated after 2024? Answer yes/no with reason.")

# Agent decides which tool to use and when to re-search
agent = create_tool_calling_agent(llm, [search_knowledge_base, search_web, check_date_relevance], prompt)
executor = AgentExecutor(agent=agent, tools=[search_knowledge_base, search_web, check_date_relevance])
Topic Quiz · 1 questions

Test your understanding before moving on

1. What makes agentic RAG different from standard RAG?
💡 Agentic RAG is dynamic — the agent reasons about retrieval strategy rather than always doing one fixed lookup.