agents.supervisor.agent¶
Dynamic Supervisor V2 - Main agent implementation.
This module contains the core DynamicSupervisor class that orchestrates runtime agent discovery, creation, and task routing.
Classes¶
Advanced supervisor that discovers and creates agents at runtime. |
Functions¶
|
Factory function to create a configured dynamic supervisor. |
Module Contents¶
- class agents.supervisor.agent.DynamicSupervisor(**data)¶
Bases:
haive.agents.react.agent.ReactAgent
Advanced supervisor that discovers and creates agents at runtime.
The DynamicSupervisor extends ReactAgent to provide intelligent task routing with the ability to discover, create, and manage specialized agents dynamically based on task requirements.
- Key capabilities:
Dynamic agent discovery from specifications
Runtime agent creation and lifecycle management
Intelligent task-to-agent matching
Performance tracking and optimization
Extensible discovery mechanisms
- name¶
Supervisor identifier
- engine¶
LLM configuration for supervisor reasoning
- agent_specs¶
Initial specifications for creatable agents
- discovery_config¶
Configuration for agent discovery
- max_agents¶
Maximum number of active agents to maintain
- auto_discover¶
Whether to automatically discover new agents
- include_management_tools¶
Whether to include agent management tools
Examples
Basic usage with predefined agent specs:
supervisor = DynamicSupervisor( name="task_router", agent_specs=[ AgentSpec( name="researcher", agent_type="ReactAgent", description="Research and analysis expert", specialties=["research", "analysis"], tools=[web_search_tool] ), AgentSpec( name="writer", agent_type="SimpleAgentV3", description="Content creation expert", specialties=["writing", "editing"] ) ] ) result = await supervisor.arun( "Research quantum computing and write a summary" )
Initialize the dynamic supervisor.
- Parameters:
**data – Configuration parameters
- async arun(input_data)¶
Run the supervisor asynchronously.
- get_metrics()¶
Get supervisor performance metrics.
- run(input_data)¶
Run the supervisor synchronously.
- agents.supervisor.agent.create_dynamic_supervisor(name='dynamic_supervisor', agent_specs=None, discovery_mode=AgentDiscoveryMode.MANUAL, **kwargs)¶
Factory function to create a configured dynamic supervisor.
- Parameters:
- Returns:
Configured DynamicSupervisor instance
- Return type:
Examples
>>> supervisor = create_dynamic_supervisor( ... name="task_router", ... agent_specs=[math_spec, research_spec], ... discovery_mode="manual", ... max_agents=20 ... )