agents.multi.enhanced_multi_agent_generic

Enhanced MultiAgent with proper generics for contained agents.

MultiAgent[AgentsT] where AgentsT represents the agents it contains.

Classes

AdaptiveBranchingMultiAgent

Branching MultiAgent that adapts routing based on performance.

BranchingMultiAgent

MultiAgent specialized for branching execution.

ConditionalMultiAgent

MultiAgent with conditional execution based on previous results.

MultiAgent

Enhanced MultiAgent generic on the agents it contains.

ReportTeamAgents

Typed dict for report team agents.

Module Contents

class agents.multi.enhanced_multi_agent_generic.AdaptiveBranchingMultiAgent

Bases: BranchingMultiAgent

Branching MultiAgent that adapts routing based on performance.

Tracks agent performance and adjusts routing probabilities.

get_best_agent_for_task(task_type)

Get best performing agent for task type.

Parameters:

task_type (str)

Return type:

str

update_performance(agent_name, success, duration)

Update agent performance metrics.

Parameters:
Return type:

None

class agents.multi.enhanced_multi_agent_generic.BranchingMultiAgent

Bases: MultiAgent[dict[str, Agent]]

MultiAgent specialized for branching execution.

Routes to different agents based on conditions.

build_graph()

Build branching execution graph.

Return type:

haive.core.graph.state_graph.base_graph2.BaseGraph

class agents.multi.enhanced_multi_agent_generic.ConditionalMultiAgent

Bases: MultiAgent[dict[str, Agent]]

MultiAgent with conditional execution based on previous results.

Executes agents conditionally based on outputs.

should_continue(state, current_agent)

Determine next agent based on conditions.

Parameters:
Return type:

str | None

class agents.multi.enhanced_multi_agent_generic.MultiAgent

Bases: Agent, Generic[AgentsT]

Enhanced MultiAgent generic on the agents it contains.

MultiAgent[AgentsT] = Agent[AugLLMConfig] + agents: AgentsT

This properly represents that MultiAgent is: 1. An agent itself (uses AugLLMConfig for coordination) 2. Generic on the agents it contains

Examples

With typed dict of agents:

agents: Dict[str, Agent] = {
    "planner": PlannerAgent(...),
    "executor": ExecutorAgent(...)
}
multi: MultiAgent[Dict[str, Agent]] = MultiAgent(
    name="coordinator",
    agents=agents
)

With list of agents:

agent_list: List[ReactAgent] = [agent1, agent2, agent3]
multi: MultiAgent[List[ReactAgent]] = MultiAgent(
    name="ensemble",
    agents=agent_list
)

With specific agent types:

from typing import TypedDict

class MyAgents(TypedDict):
    researcher: RAGAgent
    analyzer: ReactAgent
    writer: SimpleAgent

agents = MyAgents(
    researcher=rag_agent,
    analyzer=react_agent,
    writer=simple_agent
)

multi: MultiAgent[MyAgents] = MultiAgent(
    name="report_team",
    agents=agents
)
get_agent(name)

Get agent by name.

Parameters:

name (str)

Return type:

Agent | None

get_agent_names()

Get list of agent names.

Return type:

list[str]

classmethod validate_agents(v)

Validate agents based on type.

Parameters:

v (AgentsT)

Return type:

AgentsT

class agents.multi.enhanced_multi_agent_generic.ReportTeamAgents

Bases: TypedDict

Typed dict for report team agents.

Initialize self. See help(type(self)) for accurate signature.