agents.supervisor.core.simple_supervisor¶
SimpleSupervisor - Lightweight supervisor for basic routing needs.
This module provides the SimpleSupervisor class, a lightweight alternative to SupervisorAgent that extends MultiAgent instead of ReactAgent. It’s designed for scenarios where you need simple routing without the overhead of ReactAgent’s looping behavior.
Current Status: This is a lightweight supervisor for simple use cases. For full-featured supervision with tool execution, use SupervisorAgent. For dynamic agent management, use DynamicSupervisor.
The SimpleSupervisor uses an LLM to make routing decisions but executes in a single pass without the continuous looping of ReactAgent-based supervisors.
- Key Features:
Lightweight design: Extends MultiAgent for minimal overhead
Single-pass execution: No continuous looping
LLM routing: Intelligent agent selection
Clean API: Simple agent registration with descriptions
Custom prompts: Configurable routing prompts
Direct execution: Routes and executes in one step
- Use Cases:
Simple request routing to specialized agents
One-shot task delegation
Lightweight agent coordination
When ReactAgent features aren’t needed
Example
Basic routing setup:
>>> from haive.agents.supervisor import SimpleSupervisor
>>> from haive.agents.simple import SimpleAgent
>>> from haive.core.engine.aug_llm import AugLLMConfig
>>>
>>> # Create specialized agents
>>> calculator = SimpleAgent(name="calculator", engine=config)
>>> writer = SimpleAgent(name="writer", engine=config)
>>>
>>> # Create simple supervisor
>>> supervisor = SimpleSupervisor(
... name="router",
... engine=AugLLMConfig(temperature=0.3),
... agents={
... "calculator": AgentInfo(
... agent=calculator,
... description="Handles math and calculations"
... ),
... "writer": AgentInfo(
... agent=writer,
... description="Handles writing and content creation"
... )
... }
... )
>>>
>>> # Single-pass routing and execution
>>> result = await supervisor.arun("Calculate 15% of 200")
Custom routing prompt:
>>> custom_prompt = ChatPromptTemplate.from_template(
... "Route this request to the best agent: {query}\\n"
... "Agents: {agent_descriptions}\\n"
... "Choice:"
... )
>>>
>>> supervisor = SimpleSupervisor(
... name="custom_router",
... engine=config,
... prompt_template=custom_prompt,
... agents={...}
... )
See also
haive.agents.supervisor.SupervisorAgent
: Full-featured supervisorhaive.agents.supervisor.DynamicSupervisor
: Dynamic agent managementhaive.agents.multi.MultiAgent
: Base class
Classes¶
Information about a registered agent. |
|
Simple supervisor that routes between agents using LLM decisions. |
Module Contents¶
- class agents.supervisor.core.simple_supervisor.AgentInfo(/, **data)¶
Bases:
pydantic.BaseModel
Information about a registered 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.core.simple_supervisor.SimpleSupervisor¶
Bases:
haive.agents.multi.archive.multi_agent.MultiAgent
Simple supervisor that routes between agents using LLM decisions.
This supervisor: 1. Accepts a user message 2. Uses an LLM to decide which agent should handle it 3. Routes to that agent 4. Returns the agent’s response
The routing decision is based on agent descriptions and conversation context.
- build_graph()¶
Build supervisor graph with dynamic routing.
- Return type:
haive.core.graph.state_graph.base_graph2.BaseGraph
- classmethod create_with_agents(agents, name='supervisor', supervisor_llm=None, **kwargs)¶
Create supervisor with a list of agents.
- Parameters:
- Returns:
SimpleSupervisor instance
- Return type:
Examples
- supervisor = SimpleSupervisor.create_with_agents([
(“writer”, writer_agent, “Writes creative content”), (“coder”, coder_agent, “Writes and reviews code”), (“analyst”, analyst_agent, “Analyzes data and trends”)
])
- register_agent(name, agent, description)¶
Register an agent with the supervisor.
- setup_agent()¶
Setup supervisor with routing LLM.
- Return type:
None