agents.react_class.react_agent2.dynamic_agentΒΆ

Dynamic React Agent - an extension of React agent with tool selection capabilities.

ClassesΒΆ

DynamicReactAgent

A React agent with dynamic tool selection.

DynamicReactAgentConfig

Configuration for a React agent with dynamic tool selection.

DynamicReactAgentState

Extended schema for dynamic tool selection.

FunctionsΒΆ

create_dynamic_react_agent(tools[, system_prompt, ...])

Create a dynamic react agent with minimal configuration.

Module ContentsΒΆ

class agents.react_class.react_agent2.dynamic_agent.DynamicReactAgent(config)ΒΆ

Bases: haive.agents.react_class.react_agent2.agent2.ReactAgent

A React agent with dynamic tool selection.

This agent extends the React pattern with dynamic tool selection, making it efficient when dealing with a large number of tools.

Initialize the dynamic react agent.

Parameters:

config (DynamicReactAgentConfig)

register_tools(tools)ΒΆ

Register tools with the agent and create tool embeddings.

Parameters:

tools (list[langchain_core.tools.BaseTool]) – List of tools to register

Return type:

None

run(input_data, **kwargs)ΒΆ

Run the agent with the given input.

Parameters:
  • input_data (str | list[str] | dict[str, Any] | pydantic.BaseModel) – Input data in various formats

  • **kwargs – Additional runtime configuration

Returns:

Final state or output

Return type:

dict[str, Any]

setup_workflow()ΒΆ

Set up the workflow with dynamic tool selection.

Return type:

None

property vector_store: AnyΒΆ

Get the vector store property.

Return type:

Any

class agents.react_class.react_agent2.dynamic_agent.DynamicReactAgentConfigΒΆ

Bases: haive.agents.react_class.react_agent2.config2.ReactAgentConfig

Configuration for a React agent with dynamic tool selection.

This agent can handle a large number of tools by dynamically selecting which tools to make available to the LLM based on the context.

classmethod from_tools(tools, system_prompt=None, model='gpt-4o', temperature=0.7, name=None, max_tools_per_turn=5, max_iterations=10, response_format=None, use_memory=True, visualize=True, repeat_selection=True, **kwargs)ΒΆ

Create a DynamicReactAgentConfig from a list of tools.

Parameters:
  • tools (list[langchain_core.tools.BaseTool]) – List of tools to use

  • system_prompt (str | None) – Optional system prompt

  • model (str) – Model name

  • temperature (float) – Temperature for generation

  • name (str | None) – Optional agent name

  • max_tools_per_turn (int) – Maximum number of tools to select per turn

  • max_iterations (int) – Maximum iterations for React agent

  • response_format (type[pydantic.BaseModel] | dict[str, Any] | None) – Optional structured output model

  • use_memory (bool) – Whether to use memory

  • visualize (bool) – Whether to visualize the graph

  • repeat_selection (bool) – Whether to repeat tool selection after each tool invocation

  • **kwargs – Additional kwargs for the config

Returns:

DynamicReactAgentConfig instance

Return type:

DynamicReactAgentConfig

class agents.react_class.react_agent2.dynamic_agent.DynamicReactAgentState(/, **data)ΒΆ

Bases: haive.agents.react_class.react_agent2.state2.ReactAgentState

Extended schema for dynamic tool selection.

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)

model_configΒΆ

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

agents.react_class.react_agent2.dynamic_agent.create_dynamic_react_agent(tools, system_prompt=None, model='gpt-4o', temperature=0.7, name=None, max_tools_per_turn=5, max_iterations=10, response_format=None, use_memory=True, visualize=True, repeat_selection=True, vector_store_config=None, tool_documents=None, **kwargs)ΒΆ

Create a dynamic react agent with minimal configuration.

Parameters:
  • tools (list[langchain_core.tools.BaseTool]) – List of tools the agent can use

  • system_prompt (str | None) – Optional system prompt

  • model (str) – Model name to use

  • temperature (float) – Temperature for generation

  • name (str | None) – Optional agent name

  • max_tools_per_turn (int) – Maximum number of tools to select per turn

  • max_iterations (int) – Maximum iterations for React agent

  • response_format (type[pydantic.BaseModel] | dict[str, Any] | None) – Optional structured output model

  • use_memory (bool) – Whether to use memory

  • visualize (bool) – Whether to visualize the graph

  • repeat_selection (bool) – Whether to repeat tool selection after each tool invocation

  • vector_store_config (haive.core.models.vectorstore.base.VectorStoreConfig | None) – Optional vector store configuration

  • tool_documents (list[langchain_core.documents.Document] | None) – Optional pre-created tool documents

  • **kwargs – Additional configuration parameters

Returns:

DynamicReactAgent instance

Return type:

DynamicReactAgent