haive.agents.supervisor.dynamic.dynamic_agent_tools
===================================================
.. py:module:: haive.agents.supervisor.dynamic.dynamic_agent_tools
.. autoapi-nested-parse::
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
-------
.. autoapisummary::
haive.agents.supervisor.dynamic.dynamic_agent_tools.AddAgentInput
haive.agents.supervisor.dynamic.dynamic_agent_tools.AddAgentTool
haive.agents.supervisor.dynamic.dynamic_agent_tools.AgentDescriptor
haive.agents.supervisor.dynamic.dynamic_agent_tools.AgentRegistryManager
haive.agents.supervisor.dynamic.dynamic_agent_tools.AgentSelectorTool
haive.agents.supervisor.dynamic.dynamic_agent_tools.ChangeAgentInput
haive.agents.supervisor.dynamic.dynamic_agent_tools.ChangeAgentTool
haive.agents.supervisor.dynamic.dynamic_agent_tools.ListAgentsInput
haive.agents.supervisor.dynamic.dynamic_agent_tools.ListAgentsTool
haive.agents.supervisor.dynamic.dynamic_agent_tools.RemoveAgentInput
haive.agents.supervisor.dynamic.dynamic_agent_tools.RemoveAgentTool
Functions
---------
.. autoapisummary::
haive.agents.supervisor.dynamic.dynamic_agent_tools.create_agent_management_tools
haive.agents.supervisor.dynamic.dynamic_agent_tools.register_agent_constructor
Module Contents
---------------
.. py:class:: AddAgentInput(/, **data)
Bases: :py:obj:`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.
.. py:class:: AddAgentTool(registry_manager)
Bases: :py:obj:`langchain_core.tools.BaseTool`
Tool for dynamically adding agents to the supervisor.
Init .
:param registry_manager: [TODO: Add description]
.. py:attribute:: args_schema
:type: type[pydantic.BaseModel] | None
:value: 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
.. py:attribute:: description
:type: str
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""Add a new agent to the supervisor's registry.
This allows the supervisor to route requests to the new agent."""
.. raw:: html
Used to tell the model how/when/why to use the tool.
You can provide few-shot examples as a part of the description.
.. py:attribute:: name
:type: str
:value: 'add_agent'
The unique name of the tool that clearly communicates its purpose.
.. py:class:: AgentDescriptor(/, **data)
Bases: :py:obj:`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.
.. py:class:: AgentRegistryManager(supervisor_agent)
Manages dynamic agent registry with tool integration.
Initialize with supervisor agent reference.
.. py:method:: create_agent_from_descriptor(descriptor)
Create an agent instance from descriptor.
.. py:method:: get_agent_choice_model()
Get current agent choice model.
.. py:method:: register_agent_constructor(agent_type, constructor)
Register an agent constructor function.
.. py:class:: AgentSelectorTool(registry_manager)
Bases: :py:obj:`langchain_core.tools.BaseTool`
Tool for selecting which agent to use for the next task.
Init .
:param registry_manager: [TODO: Add description]
.. py:attribute:: args_schema
:type: type[pydantic.BaseModel] | None
:value: 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
.. py:attribute:: description
:type: str
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""Select a specific agent to handle the next user request.
Use this when you want to explicitly route to a particular agent."""
.. raw:: html
Used to tell the model how/when/why to use the tool.
You can provide few-shot examples as a part of the description.
.. py:attribute:: name
:type: str
:value: 'select_agent'
The unique name of the tool that clearly communicates its purpose.
.. py:class:: ChangeAgentInput(/, **data)
Bases: :py:obj:`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.
.. py:class:: ChangeAgentTool(registry_manager)
Bases: :py:obj:`langchain_core.tools.BaseTool`
Tool for updating agent configuration.
Init .
:param registry_manager: [TODO: Add description]
.. py:attribute:: args_schema
:type: type[pydantic.BaseModel] | None
:value: 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
.. py:attribute:: description
:type: str
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""Update configuration of an existing agent.
Can modify priority, timeout, and other execution parameters."""
.. raw:: html
Used to tell the model how/when/why to use the tool.
You can provide few-shot examples as a part of the description.
.. py:attribute:: name
:type: str
:value: 'change_agent'
The unique name of the tool that clearly communicates its purpose.
.. py:class:: ListAgentsInput(/, **data)
Bases: :py:obj:`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.
.. py:class:: ListAgentsTool(registry_manager)
Bases: :py:obj:`langchain_core.tools.BaseTool`
Tool for listing available agents and their capabilities.
Init .
:param registry_manager: [TODO: Add description]
.. py:attribute:: args_schema
:type: type[pydantic.BaseModel] | None
:value: 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
.. py:attribute:: description
:type: str
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""List all available agents in the supervisor registry.
with their capabilities and performance metrics."""
.. raw:: html
Used to tell the model how/when/why to use the tool.
You can provide few-shot examples as a part of the description.
.. py:attribute:: name
:type: str
:value: 'list_agents'
The unique name of the tool that clearly communicates its purpose.
.. py:class:: RemoveAgentInput(/, **data)
Bases: :py:obj:`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.
.. py:class:: RemoveAgentTool(registry_manager)
Bases: :py:obj:`langchain_core.tools.BaseTool`
Tool for dynamically removing agents from the supervisor.
Init .
:param registry_manager: [TODO: Add description]
.. py:attribute:: args_schema
:type: type[pydantic.BaseModel] | None
:value: 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
.. py:attribute:: description
:type: str
:value: Multiline-String
.. raw:: html
Show Value
.. code-block:: python
"""Remove an agent from the supervisor's registry.
The agent will no longer be available for routing."""
.. raw:: html
Used to tell the model how/when/why to use the tool.
You can provide few-shot examples as a part of the description.
.. py:attribute:: name
:type: str
:value: 'remove_agent'
The unique name of the tool that clearly communicates its purpose.
.. py:function:: create_agent_management_tools(supervisor_agent)
Create all agent management tools for a supervisor.
.. py:function:: register_agent_constructor(supervisor_agent, agent_type, constructor)
Register an agent constructor with the supervisor's registry manager.