haive.core.engine.tool.engine

Rebuilt ToolEngine with universal typing and advanced features.

Classes

ToolEngine

Enhanced tool engine with universal typing and property analysis.

Module Contents

class haive.core.engine.tool.engine.ToolEngine[source]

Bases: haive.core.engine.base.InvokableEngine[dict[str, Any], dict[str, Any]]

Enhanced tool engine with universal typing and property analysis.

This engine manages tools with comprehensive property analysis, capability-based routing, and state interaction tracking.

classmethod augment_tool(tool, *, name=None, description=None, make_interruptible=False, interrupt_message='Tool execution interrupted', reads_state=False, writes_state=False, state_keys=None, structured_output_model=None)[source]

Augment an existing tool with additional capabilities.

This method adds capabilities to a tool without creating nested wrappers. All capabilities are added directly to the tool instance.

Parameters:
  • tool (langchain_core.tools.StructuredTool | langchain_core.tools.base.BaseTool | collections.abc.Callable[Ellipsis, Any])

  • name (str | None)

  • description (str | None)

  • make_interruptible (bool)

  • interrupt_message (str)

  • reads_state (bool)

  • writes_state (bool)

  • state_keys (list[str] | None)

  • structured_output_model (type[pydantic.BaseModel] | None)

Return type:

langchain_core.tools.StructuredTool

classmethod create_human_interrupt_tool(name='human_interrupt', description='Request human intervention or approval', *, allow_ignore=True, allow_respond=True, allow_edit=False, allow_accept=True, interrupt_message='Human input requested')[source]

Create a tool that triggers human interrupt workflow.

This creates a tool that can pause graph execution and request human intervention, following langgraph’s interrupt patterns.

Parameters:
  • name (str) – Tool name

  • description (str) – Tool description

  • allow_ignore (bool) – Whether human can skip/ignore

  • allow_respond (bool) – Whether human can provide text response

  • allow_edit (bool) – Whether human can edit the request

  • allow_accept (bool) – Whether human can accept as-is

  • interrupt_message (str) – Default interrupt message

Returns:

A StructuredTool that triggers human interrupts

Return type:

langchain_core.tools.StructuredTool

classmethod create_interruptible_tool(func, name=None, description=None, *, interrupt_message='Tool execution interrupted')[source]

Create or wrap a tool with interruption capability.

Parameters:
  • func (collections.abc.Callable[Ellipsis, Any] | langchain_core.tools.StructuredTool | langchain_core.tools.base.BaseTool)

  • name (str | None)

  • description (str | None)

  • interrupt_message (str)

Return type:

langchain_core.tools.StructuredTool

classmethod create_retriever_tool(retriever, name, description, *, document_prompt=None, document_separator='\n\n', response_format='content')[source]

Create a tool to do retrieval of documents.

Parameters:
  • retriever (langchain_core.retrievers.BaseRetriever)

  • name (str)

  • description (str)

  • document_prompt (langchain_core.prompts.BasePromptTemplate | None)

  • document_separator (str)

  • response_format (Literal['content', 'content_and_artifact'])

Return type:

langchain_core.tools.StructuredTool

classmethod create_retriever_tool_from_config(retriever_config, name, description, *, document_prompt=None, document_separator='\n\n', response_format='content')[source]

Create a retriever tool from a Haive retriever configuration.

This is a convenience method that creates a retriever from the config and then converts it to a tool with proper metadata.

Parameters:
  • retriever_config (Any) – The BaseRetrieverConfig to use

  • name (str) – Tool name

  • description (str) – Tool description

  • document_prompt (langchain_core.prompts.BasePromptTemplate | None) – Optional prompt to format documents

  • document_separator (str) – Separator between documents

  • response_format (Literal['content', 'content_and_artifact']) – Format for tool response

Returns:

A StructuredTool configured for retrieval

Return type:

langchain_core.tools.StructuredTool

create_runnable(runnable_config=None)[source]

Create enhanced ToolNode with property awareness.

Parameters:

runnable_config (langchain_core.runnables.RunnableConfig | None)

Return type:

Any

classmethod create_state_tool(func, name=None, description=None, *, reads_state=False, writes_state=False, state_keys=None)[source]

Create or wrap a tool with state interaction metadata.

Parameters:
  • func (collections.abc.Callable[Ellipsis, Any] | langchain_core.tools.StructuredTool | langchain_core.tools.base.BaseTool)

  • name (str | None)

  • description (str | None)

  • reads_state (bool)

  • writes_state (bool)

  • state_keys (list[str] | None)

Return type:

langchain_core.tools.StructuredTool

classmethod create_store_tools_suite(store_manager, namespace=None, include_tools=None)[source]

Create a suite of store/memory management tools.

This creates tools for memory operations like store, search, retrieve, update, and delete. These tools integrate with the StoreManager for persistent memory management.

Parameters:
  • store_manager (Any) – The StoreManager instance to use

  • namespace (tuple[str, Ellipsis] | None) – Optional namespace for memory isolation

  • include_tools (list[str] | None) – List of tools to include (defaults to all) Options: [“store”, “search”, “retrieve”, “update”, “delete”]

Returns:

List of store tools with proper metadata

Return type:

list[langchain_core.tools.StructuredTool]

classmethod create_structured_output_tool(func, name, description, output_model, *, infer_schema=True)[source]

Create a tool that produces structured output.

Parameters:
Return type:

langchain_core.tools.StructuredTool

classmethod from_aug_llm_config(config, *, extract_tools=True, include_structured_output=True, name=None)[source]

Create ToolEngine from AugLLMConfig.

Parameters:
  • config (AugLLMConfig) – AugLLMConfig instance to convert

  • extract_tools (bool) – Whether to extract tools from config

  • include_structured_output (bool) – Whether to convert structured_output_model to tool

  • name (str | None) – Optional name for the engine

Returns:

ToolEngine with tools extracted from AugLLMConfig

Return type:

ToolEngine

classmethod from_document_engine(engine, *, create_loader_tools=True, create_splitter_tools=True, create_processor_tools=False, name=None)[source]

Create ToolEngine from DocumentEngine.

Parameters:
  • engine (DocumentEngine) – DocumentEngine instance to convert

  • create_loader_tools (bool) – Whether to create document loading tools

  • create_splitter_tools (bool) – Whether to create document splitting tools

  • create_processor_tools (bool) – Whether to create document processing tools

  • name (str | None) – Optional name for the engine

Returns:

ToolEngine with document processing tools

Return type:

ToolEngine

classmethod from_multiple_engines(engines, *, engine_conversion_config=None, name=None)[source]

Create ToolEngine from multiple engines.

Parameters:
  • engines (dict[str, haive.core.engine.base.InvokableEngine]) – Dictionary of engine_name -> engine_instance

  • engine_conversion_config (dict[str, dict] | None) – Configuration for each engine’s conversion

  • name (str | None) – Optional name for the combined engine

Returns:

ToolEngine with tools from all engines

Return type:

ToolEngine

classmethod from_retriever_config(config, *, tool_name=None, tool_description=None, name=None)[source]

Create ToolEngine from BaseRetrieverConfig.

Parameters:
  • config (BaseRetrieverConfig) – BaseRetrieverConfig instance to convert

  • tool_name (str | None) – Name for the retriever tool

  • tool_description (str | None) – Description for the retriever tool

  • name (str | None) – Optional name for the engine

Returns:

ToolEngine with retriever converted to tool

Return type:

ToolEngine

classmethod from_vectorstore_config(config, *, search_tool_name=None, similarity_search_tool=True, max_marginal_relevance_tool=False, name=None)[source]

Create ToolEngine from VectorStoreConfig.

Parameters:
  • config (haive.core.engine.vectorstore.VectorStoreConfig) – VectorStoreConfig instance to convert

  • search_tool_name (str | None) – Base name for search tools

  • similarity_search_tool (bool) – Whether to create similarity search tool

  • max_marginal_relevance_tool (bool) – Whether to create MMR search tool

  • name (str | None) – Optional name for the engine

Returns:

ToolEngine with vectorstore search tools

Return type:

ToolEngine

classmethod get_analyzer()[source]

Get a tool analyzer instance.

Return type:

haive.core.engine.tool.analyzer.ToolAnalyzer

classmethod get_capability_enum()[source]

Get ToolCapability enum for other components.

Return type:

type[haive.core.engine.tool.types.ToolCapability]

classmethod get_category_enum()[source]

Get ToolCategory enum for other components.

Return type:

type[haive.core.engine.tool.types.ToolCategory]

get_input_fields()[source]

Define input fields for tool engine.

Return type:

dict[str, tuple[type, Any]]

get_interruptible_tools()[source]

Get all interruptible tool names.

Return type:

list[str]

get_output_fields()[source]

Define output fields for tool engine.

Return type:

dict[str, tuple[type, Any]]

get_state_tools()[source]

Get all state-aware tool names.

Return type:

list[str]

get_tool_properties(tool_name)[source]

Get properties for specific tool.

Parameters:

tool_name (str)

Return type:

haive.core.engine.tool.types.ToolProperties | None

classmethod get_tool_type()[source]

Get the universal ToolLike type for other components.

Return type:

type

get_tools_by_capability(*capabilities)[source]

Get tool names with specified capabilities.

Parameters:

capabilities (haive.core.engine.tool.types.ToolCapability)

Return type:

list[str]

get_tools_by_category(category)[source]

Get tool names in category.

Parameters:

category (haive.core.engine.tool.types.ToolCategory)

Return type:

list[str]

get_tools_reading_state()[source]

Get tools that read from state.

Return type:

list[str]

get_tools_writing_state()[source]

Get tools that write to state.

Return type:

list[str]

model_post_init(__context)[source]

Initialize and analyze tools after creation.

Parameters:

__context (Any)

Return type:

None

classmethod validate_engine_type(v)[source]

Validate engine type is TOOL.

Return type:

Any

classmethod validate_tool_choice(v)[source]

Validate tool_choice has a valid value.

Return type:

Any

classmethod validate_toolkit(v)[source]

Validate toolkit is of the correct type.

Return type:

Any

classmethod validate_tools(v)[source]

Validate tools are of the correct type.

Return type:

Any