agents.supervisor.dynamic.dynamic_agent_tools¶

Dynamic Agent Management Tools for Supervisor.

from typing import Any, Optional This module provides tools that allow the supervisor to dynamically add, remove, and manage agents at runtime through tool calls, integrating with DynamicChoiceModel for routing and state management.

Classes¶

AddAgentInput

Input for adding a new agent to the supervisor.

AddAgentTool

Tool for dynamically adding agents to the supervisor.

AgentDescriptor

Descriptor for an agent that can be dynamically added.

AgentRegistryManager

Manages dynamic agent registry with tool integration.

AgentSelectorTool

Tool for selecting which agent to use for the next task.

ChangeAgentInput

Input for changing/updating an existing agent.

ChangeAgentTool

Tool for updating agent configuration.

ListAgentsInput

Input for listing available agents.

ListAgentsTool

Tool for listing available agents and their capabilities.

RemoveAgentInput

Input for removing an agent from the supervisor.

RemoveAgentTool

Tool for dynamically removing agents from the supervisor.

Functions¶

create_agent_management_tools(supervisor_agent)

Create all agent management tools for a supervisor.

register_agent_constructor(supervisor_agent, ...)

Register an agent constructor with the supervisor's registry manager.

Module Contents¶

class agents.supervisor.dynamic.dynamic_agent_tools.AddAgentInput(/, **data)¶

Bases: pydantic.BaseModel

Input for adding a new agent to the supervisor.

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)

class agents.supervisor.dynamic.dynamic_agent_tools.AddAgentTool(registry_manager)¶

Bases: langchain_core.tools.BaseTool

Tool for dynamically adding agents to the supervisor.

Init .

Parameters:

registry_manager (AgentRegistryManager) – [TODO: Add description]

args_schema: type[pydantic.BaseModel] | None = None¶

Pydantic model class to validate and parse the tool’s input arguments.

Args schema should be either:

  • A subclass of pydantic.BaseModel.

  • A subclass of pydantic.v1.BaseModel if accessing v1 namespace in pydantic 2

  • a JSON schema dict

description: str = Multiline-String¶
Show Value
"""Add a new agent to the supervisor's registry.
    This allows the supervisor to route requests to the new agent."""

Used to tell the model how/when/why to use the tool.

You can provide few-shot examples as a part of the description.

name: str = 'add_agent'¶

The unique name of the tool that clearly communicates its purpose.

class agents.supervisor.dynamic.dynamic_agent_tools.AgentDescriptor(/, **data)¶

Bases: pydantic.BaseModel

Descriptor for an agent that can be dynamically added.

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)

class agents.supervisor.dynamic.dynamic_agent_tools.AgentRegistryManager(supervisor_agent)¶

Manages dynamic agent registry with tool integration.

Initialize with supervisor agent reference.

Parameters:

supervisor_agent (Any)

create_agent_from_descriptor(descriptor)¶

Create an agent instance from descriptor.

Parameters:

descriptor (AgentDescriptor)

Return type:

haive.agents.base.agent.Agent | None

get_agent_choice_model()¶

Get current agent choice model.

Return type:

haive.core.common.models.dynamic_choice_model.DynamicChoiceModel[str]

register_agent_constructor(agent_type, constructor)¶

Register an agent constructor function.

Parameters:

agent_type (str)

class agents.supervisor.dynamic.dynamic_agent_tools.AgentSelectorTool(registry_manager)¶

Bases: langchain_core.tools.BaseTool

Tool for selecting which agent to use for the next task.

Init .

Parameters:

registry_manager (AgentRegistryManager) – [TODO: Add description]

args_schema: type[pydantic.BaseModel] | None = None¶

Pydantic model class to validate and parse the tool’s input arguments.

Args schema should be either:

  • A subclass of pydantic.BaseModel.

  • A subclass of pydantic.v1.BaseModel if accessing v1 namespace in pydantic 2

  • a JSON schema dict

description: str = Multiline-String¶
Show Value
"""Select a specific agent to handle the next user request.
    Use this when you want to explicitly route to a particular agent."""

Used to tell the model how/when/why to use the tool.

You can provide few-shot examples as a part of the description.

name: str = 'select_agent'¶

The unique name of the tool that clearly communicates its purpose.

class agents.supervisor.dynamic.dynamic_agent_tools.ChangeAgentInput(/, **data)¶

Bases: pydantic.BaseModel

Input for changing/updating an existing 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)

class agents.supervisor.dynamic.dynamic_agent_tools.ChangeAgentTool(registry_manager)¶

Bases: langchain_core.tools.BaseTool

Tool for updating agent configuration.

Init .

Parameters:

registry_manager (AgentRegistryManager) – [TODO: Add description]

args_schema: type[pydantic.BaseModel] | None = None¶

Pydantic model class to validate and parse the tool’s input arguments.

Args schema should be either:

  • A subclass of pydantic.BaseModel.

  • A subclass of pydantic.v1.BaseModel if accessing v1 namespace in pydantic 2

  • a JSON schema dict

description: str = Multiline-String¶
Show Value
"""Update configuration of an existing agent.
    Can modify priority, timeout, and other execution parameters."""

Used to tell the model how/when/why to use the tool.

You can provide few-shot examples as a part of the description.

name: str = 'change_agent'¶

The unique name of the tool that clearly communicates its purpose.

class agents.supervisor.dynamic.dynamic_agent_tools.ListAgentsInput(/, **data)¶

Bases: pydantic.BaseModel

Input for listing available agents.

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)

class agents.supervisor.dynamic.dynamic_agent_tools.ListAgentsTool(registry_manager)¶

Bases: langchain_core.tools.BaseTool

Tool for listing available agents and their capabilities.

Init .

Parameters:

registry_manager (AgentRegistryManager) – [TODO: Add description]

args_schema: type[pydantic.BaseModel] | None = None¶

Pydantic model class to validate and parse the tool’s input arguments.

Args schema should be either:

  • A subclass of pydantic.BaseModel.

  • A subclass of pydantic.v1.BaseModel if accessing v1 namespace in pydantic 2

  • a JSON schema dict

description: str = Multiline-String¶
Show Value
"""List all available agents in the supervisor registry.
    with their capabilities and performance metrics."""

Used to tell the model how/when/why to use the tool.

You can provide few-shot examples as a part of the description.

name: str = 'list_agents'¶

The unique name of the tool that clearly communicates its purpose.

class agents.supervisor.dynamic.dynamic_agent_tools.RemoveAgentInput(/, **data)¶

Bases: pydantic.BaseModel

Input for removing an agent from the supervisor.

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)

class agents.supervisor.dynamic.dynamic_agent_tools.RemoveAgentTool(registry_manager)¶

Bases: langchain_core.tools.BaseTool

Tool for dynamically removing agents from the supervisor.

Init .

Parameters:

registry_manager (AgentRegistryManager) – [TODO: Add description]

args_schema: type[pydantic.BaseModel] | None = None¶

Pydantic model class to validate and parse the tool’s input arguments.

Args schema should be either:

  • A subclass of pydantic.BaseModel.

  • A subclass of pydantic.v1.BaseModel if accessing v1 namespace in pydantic 2

  • a JSON schema dict

description: str = Multiline-String¶
Show Value
"""Remove an agent from the supervisor's registry.
    The agent will no longer be available for routing."""

Used to tell the model how/when/why to use the tool.

You can provide few-shot examples as a part of the description.

name: str = 'remove_agent'¶

The unique name of the tool that clearly communicates its purpose.

agents.supervisor.dynamic.dynamic_agent_tools.create_agent_management_tools(supervisor_agent)¶

Create all agent management tools for a supervisor.

Parameters:

supervisor_agent (Any)

Return type:

list[langchain_core.tools.BaseTool]

agents.supervisor.dynamic.dynamic_agent_tools.register_agent_constructor(supervisor_agent, agent_type, constructor)¶

Register an agent constructor with the supervisor’s registry manager.

Parameters:
  • supervisor_agent (Any)

  • agent_type (str)