agents.experiments.dynamic_supervisorΒΆ
Dynamic Supervisor Agent Experiment.
from typing import Any This module contains experimental implementation of a dynamic supervisor that can select and execute agents based on runtime decisions.
ClassesΒΆ
Registry for managing available agents. |
|
Registry entry for an agent. |
|
Dynamic supervisor that selects and executes agents at runtime. |
|
State schema for dynamic supervisor agent. |
FunctionsΒΆ
|
Create a handoff tool for a specific agent. |
|
Create a tool to forward agent messages. |
|
Create a tool to list available agents. |
Create a test registry with some mock agents. |
|
Test dynamic tool creation and handoff functionality. |
|
Basic test of supervisor functionality. |
|
Test a complete supervisor workflow. |
Module ContentsΒΆ
- class agents.experiments.dynamic_supervisor.AgentRegistryΒΆ
Registry for managing available agents.
Init .
- Returns:
Add return description]
- Return type:
[TODO
- instantiate_agent(name)ΒΆ
Instantiate an agent from the registry.
- Parameters:
name (str)
- Return type:
haive.agents.base.agent.Agent | None
- list_agents()ΒΆ
List all registered agents with their metadata.
- register(name, description, agent_class, config=None, capabilities=None)ΒΆ
Register an agent with the registry.
- to_state_format()ΒΆ
Convert registry to format suitable for SupervisorState.
- class agents.experiments.dynamic_supervisor.AgentRegistryEntry(/, **data)ΒΆ
Bases:
pydantic.BaseModel
Registry entry for an agent.
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].
- class agents.experiments.dynamic_supervisor.DynamicSupervisorAgent(/, **data)ΒΆ
Bases:
haive.agents.react.agent.ReactAgent
Dynamic supervisor that selects and executes agents at runtime.
This agent inherits from ReactAgent to get the looping behavior needed for continuous agent selection and execution. It dynamically creates handoff tools for each agent in the registry.
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)
- add_agent_to_registry(name, description, agent_class, config=None)ΒΆ
Dynamically add an agent to the registry and update tools.
- remove_agent_from_registry(name)ΒΆ
Dynamically remove an agent from the registry and update tools.
- Parameters:
name (str)
- setup_agent()ΒΆ
Setup supervisor with dynamic agent tools.
- Return type:
None
- class agents.experiments.dynamic_supervisor.SupervisorState(/, **data)ΒΆ
Bases:
haive.core.schema.prebuilt.messages_state.MessagesState
State schema for dynamic supervisor agent.
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)
- agents.experiments.dynamic_supervisor.create_dynamic_handoff_tool(supervisor_instance, agent_name)ΒΆ
Create a handoff tool for a specific agent.
- Parameters:
agent_name (str)
- agents.experiments.dynamic_supervisor.create_forward_message_tool(supervisor_name='supervisor')ΒΆ
Create a tool to forward agent messages.
- Parameters:
supervisor_name (str)
- agents.experiments.dynamic_supervisor.create_list_agents_tool(supervisor_instance)ΒΆ
Create a tool to list available agents.
- Return type:
Any
- agents.experiments.dynamic_supervisor.create_test_registry()ΒΆ
Create a test registry with some mock agents.
- Return type:
- agents.experiments.dynamic_supervisor.test_dynamic_tools()ΒΆ
Test dynamic tool creation and handoff functionality.
- Return type:
Any
- agents.experiments.dynamic_supervisor.test_supervisor_basic()ΒΆ
Basic test of supervisor functionality.
- Return type:
Any
- agents.experiments.dynamic_supervisor.test_supervisor_workflow()ΒΆ
Test a complete supervisor workflow.
- Return type:
Any