agents.react_class.react_v3.agentΒΆ

ReactAgent implementation with tool usage and ReAct pattern.

from typing import Any, Dict This module implements a tool-using agent that follows the ReAct pattern (Reasoning, Acting, and Observing) for solving tasks.

ClassesΒΆ

ReactAgent

A tool-using agent implementing the ReAct pattern.

Module ContentsΒΆ

class agents.react_class.react_v3.agent.ReactAgent(config, verbose=False, rich_logging=True)ΒΆ

Bases: haive.core.engine.agent.agent.Agent[haive.agents.react_class.react_v3.config.ReactAgentConfig]

A tool-using agent implementing the ReAct pattern.

Features: - Integration with LangChain tools - Automatic schema composition from tools and engine - Reasoning β†’ Tool Use β†’ Observation cycle - Retry policies for resilience - Configurable termination conditions

Initialize the agent with its configuration.

Parameters:
  • config (TConfig) – Agent configuration

  • verbose (bool) – Whether to enable verbose logging

  • rich_logging (bool) – Whether to use rich UI for logging and debugging

classmethod from_langgraph(react_state_graph, **kwargs)ΒΆ

Create a ReactAgent from an existing LangGraph StateGraph.

This allows using LangGraph’s create_react_agent directly and then wrapping it with our ReactAgent class.

Parameters:
  • react_state_graph (langgraph.graph.StateGraph) – Existing React agent StateGraph

  • **kwargs – Additional configuration parameters

Returns:

ReactAgent instance wrapping the provided StateGraph

Return type:

ReactAgent

classmethod from_tools(tools, llm=None, system_prompt=None, **kwargs)ΒΆ

Create a ReactAgent from a list of tools.

Parameters:
  • tools (list[Any]) – List of tools to use

  • llm (haive.core.engine.aug_llm.AugLLMConfig | None) – Optional LLM configuration (auto-created if not provided)

  • system_prompt (str | None) – Optional system prompt

  • **kwargs – Additional configuration parameters

Returns:

Configured ReactAgent instance

Return type:

ReactAgent

run(input_data)ΒΆ

Run the agent on the provided input.

Parameters:

input_data (Any) – Input in various formats

Returns:

Agent result

Return type:

Any

setup_workflow()ΒΆ

Set up the ReAct workflow with reasoning and tool execution nodes.

This creates a graph with: 1. A reasoning node that decides what to do 2. A tool execution node that carries out actions 3. Conditional branching based on message types

Return type:

None