agents.supervisor.toolsΒΆ
Tools and utilities for Dynamic Supervisor V2.
This module provides tools for agent creation, discovery, matching, and workflow coordination.
ClassesΒΆ
Collection of tools for managing agents in the supervisor. |
FunctionsΒΆ
|
Create an agent instance from a specification. |
|
Create a tool for handing off tasks to a specific agent. |
|
Discover new agents based on task requirements. |
|
Find agent specifications that match a given task. |
Module ContentsΒΆ
- class agents.supervisor.tools.AgentManagementToolsΒΆ
Collection of tools for managing agents in the supervisor.
These tools can be provided to the supervisor to enable dynamic agent management capabilities.
- static create_agent_stats_tool(state_accessor)ΒΆ
Create a tool for viewing agent statistics.
- Parameters:
state_accessor β Function to access current state
- Returns:
Tool for viewing agent stats
- Return type:
langchain_core.tools.BaseTool
- static create_list_agents_tool(state_accessor)ΒΆ
Create a tool for listing available agents.
- Parameters:
state_accessor β Function to access current state
- Returns:
Tool for listing agents
- Return type:
langchain_core.tools.BaseTool
- agents.supervisor.tools.create_agent_from_spec(spec)ΒΆ
Create an agent instance from a specification.
This function instantiates the appropriate agent type based on the spec, configuring it with the provided settings and tools.
- Parameters:
spec (haive.agents.supervisor.models.AgentSpec) β Agent specification containing type, config, and tools
- Returns:
Instantiated agent instance
- Raises:
ValueError β If agent_type is not supported
- Return type:
Any
Examples
>>> spec = AgentSpec( ... name="calculator", ... agent_type="ReactAgent", ... config={"temperature": 0.1} ... ) >>> agent = create_agent_from_spec(spec)
- agents.supervisor.tools.create_handoff_tool(agent_name, description)ΒΆ
Create a tool for handing off tasks to a specific agent.
- Parameters:
- Returns:
Tool that can be used to route tasks to the agent
- Return type:
langchain_core.tools.BaseTool
Examples
>>> tool = create_handoff_tool("math_expert", "Handles math problems") >>> result = tool.invoke({"task": "Calculate 2+2"})
- agents.supervisor.tools.discover_agents(task, discovery_config, existing_agents=None)ΒΆ
Discover new agents based on task requirements.
This function implements various discovery strategies to find or create agent specifications that can handle the given task.
- Parameters:
- Returns:
List of discovered agent specifications
- Return type:
list[haive.agents.supervisor.models.AgentSpec]
Note
Currently implements MANUAL mode. Other modes (COMPONENT_DISCOVERY, RAG_DISCOVERY, MCP_DISCOVERY) are planned for future releases.
- agents.supervisor.tools.find_matching_agent_specs(task, available_specs, threshold=0.3, max_results=5)ΒΆ
Find agent specifications that match a given task.
Uses specialty matching and keyword analysis to find the most suitable agent specifications for a task.
- Parameters:
- Returns:
List of matching specs, sorted by relevance
- Return type:
list[haive.agents.supervisor.models.AgentSpec]
Examples
>>> specs = [math_spec, research_spec, writing_spec] >>> matches = find_matching_agent_specs( ... "Calculate the compound interest", ... specs ... ) >>> assert matches[0].name == "math_expert"