Agentic RAG
Agentic execution is intentionally separate fromRAGPipeline. An
AgenticPipeline asks an agent for one decision at a time, executes selected
tools, records observations, and stops after an explicit step budget.
Basic Ollama pipeline
LLMPlannerAgent requests strict JSON decisions from the injected
LLM. A small local model may need a stronger instruction-following replacement
if it cannot reliably produce valid decisions.
Built-in retrieval tool
Every agentic pipeline registersretrieve. The tool accepts a query and an
optional top_k, uses the injected vector store, applies the optional
reranker, and adds returned documents to RAGResponse.sources.
The retrieve name is reserved and cannot be replaced by an application tool.
Add a Python tool
ToolResult, synchronously or asynchronously.
Tool exceptions become failed observations so the agent can recover on its
next decision.
Inject a custom agent
Custom agents implement one structural method and require no inheritance:agent=RetrievalFirstAgent() to AgenticPipeline.
Asynchronous tools
Use the async entry point when an agent or tool performs asynchronous work:generate() inside an active event loop raises an
actionable error rather than nesting event loops.
MCP tools
Install the MCP extra and adapt a tool from a caller-managed connected client:pipeline.agenerate().
Step exhaustion
Each decision consumes one step. If no final answer is returned withinmax_steps, AgentStepLimitError exposes the trace ID, step budget, and
completed events.
Agentic sessions
Native tracing
Passtracer=LangfuseTracer() to record the root agent execution, decisions, and tool calls.
See Langfuse observability.