haive.agents.dynamic_supervisor.agent ===================================== .. py:module:: haive.agents.dynamic_supervisor.agent .. autoapi-nested-parse:: Dynamic Supervisor Agent - routes tasks to sub-agents via tool calls. The supervisor extends ReactAgent. Each sub-agent becomes a handoff tool. The LLM decides which agent to call by making tool calls. Adding or removing agents triggers graph recompilation so the LLM always sees current tools. Example:: supervisor = DynamicSupervisor(name="boss", engine=AugLLMConfig()) supervisor.add_agent(math_agent, "Solves math problems") supervisor.add_agent(writer_agent, "Writes creative content") result = supervisor.run("What is 42 * 17?") # routes to math_agent Classes ------- .. autoapisummary:: haive.agents.dynamic_supervisor.agent.DynamicSupervisor Module Contents --------------- .. py:class:: DynamicSupervisor(/, **data) Bases: :py:obj:`haive.agents.react.agent.ReactAgent` Supervisor that routes tasks to sub-agents via tool calls. Agents are added at runtime with add_agent(). Each becomes a handoff_to_{name} tool. The ReactAgent loop handles routing - the LLM makes tool calls to delegate work. 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:method:: add_agent(agent, description = None, name = None) Add a sub-agent. Creates a handoff tool and recompiles the graph. :param agent: The agent to add (must have .run() or .arun()) :param description: What this agent does (shown to LLM) :param name: Override agent name (defaults to agent.name) .. py:method:: compile(**kwargs) Compile using the LangGraph path (not SimpleAgent's create_runnable). SimpleAgent.compile() uses create_runnable() which doesn't rebuild properly after tool changes. We go through BaseGraph.to_langgraph() instead. .. py:method:: create_agent(name, system_message, description, tools = None, temperature = 0.7) Create a new agent on the fly and add it to the supervisor. :param name: Agent name :param system_message: System prompt for the new agent :param description: What this agent does :param tools: Optional tools for the new agent :param temperature: LLM temperature :returns: The created agent .. py:method:: model_post_init(__context) Store base system message before super init. .. py:method:: remove_agent(name) Remove a sub-agent and its handoff tool. .. py:property:: agents :type: dict[str, Any] Get the current agent registry.