agents.rag.agentic.react_rag_agentΒΆ

Enhanced ReactAgent with Retriever Node and Routing for Agentic RAG.

This agent extends ReactAgent to add a dedicated retrieval node to the graph, with intelligent routing between tool calls and retrieval based on the query.

ClassesΒΆ

ReactRAGAgent

Enhanced ReactAgent with a dedicated retrieval node and intelligent routing.

Module ContentsΒΆ

class agents.rag.agentic.react_rag_agent.ReactRAGAgent(/, **data)ΒΆ

Bases: haive.agents.react.ReactAgent

Enhanced ReactAgent with a dedicated retrieval node and intelligent routing.

This agent extends ReactAgent by adding a retrieval node to the graph that works alongside regular tool nodes. The agent can route between: 1. Regular tool execution (calculator, web search, etc.) 2. Retrieval from vector store/knowledge base 3. Both in combination

The routing is handled by the LLM through a special retriever tool that triggers the retrieval node when called.

Examples

# Create ReactRAG agent with both types of tools
agent = ReactRAGAgent.create_default(
name="react_rag",
retriever_config=vector_store_config,
tools=[calculator_tool, web_search_tool],
temperature=0.1
)

# The agent will intelligently decide whether to:
# 1. Use retriever for knowledge queries
# 2. Use tools for computational/action queries
# 3. Use both when needed

result = await agent.arun("What is the capital of France?")  # Uses retriever
result = await agent.arun("Calculate 15 * 23")  # Uses calculator tool
result = await agent.arun("Search for Python tutorials")  # Uses web search

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Parameters:

data (Any)

add_retriever_tool(retriever_config)ΒΆ

Add or update the retriever tool and rebuild graph.

Parameters:

retriever_config (haive.core.engine.retriever.BaseRetrieverConfig | haive.core.engine.vectorstore.VectorStoreConfig) – New retriever configuration

Return type:

None

build_graph()ΒΆ

Build the enhanced React graph with retrieval node.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

classmethod create_default(**kwargs)ΒΆ

Create a default ReactRAG agent with retriever and tools.

Parameters:

**kwargs – Configuration options - name: Agent name - retriever_config: Retriever or vector store config - tools: List of regular tools - temperature: LLM temperature - routing_strategy: How to route between retriever and tools - engine: Custom AugLLMConfig if needed

Returns:

ReactRAGAgent configured for RAG with tools

Return type:

ReactRAGAgent

classmethod from_vectorstore(vector_store_config, **kwargs)ΒΆ

Create ReactRAG agent from a vector store configuration.

Parameters:
  • vector_store_config (haive.core.engine.vectorstore.VectorStoreConfig) – Vector store configuration

  • **kwargs – Additional agent configuration

Returns:

ReactRAGAgent with retriever tool

Return type:

ReactRAGAgent