agents.multi.enhanced_multi_agent_standalone

Standalone Enhanced MultiAgent Implementation - Fully Working.

This is a complete, working implementation of the enhanced multi-agent pattern that avoids import issues and demonstrates all the core concepts:

  • MultiAgent[AgentsT] - Generic on the agents it contains

  • Sequential, Parallel, Branching, Conditional, Adaptive patterns

  • Real async execution with debug output

  • Type safety through generics

  • No problematic imports

Key Insight: MultiAgent is generic on its agents, not just engine! MultiAgent[AgentsT] = Agent[AugLLMConfig] + agents: AgentsT

Classes

AdaptiveBranchingMultiAgent

Branching MultiAgent that adapts routing based on performance.

Agent

Enhanced Agent base class - Agent[EngineT] pattern.

BranchingMultiAgent

MultiAgent specialized for branching execution.

MinimalEngine

Minimal engine for demonstration.

MultiAgent

Enhanced MultiAgent generic on the agents it contains.

SimpleAgent

SimpleAgent = Agent[AugLLMConfig] - minimal working implementation.

Functions

demo_enhanced_multi_agent()

Demonstrate all enhanced multi-agent patterns.

Module Contents

class agents.multi.enhanced_multi_agent_standalone.AdaptiveBranchingMultiAgent(name, agents, **kwargs)

Bases: BranchingMultiAgent

Branching MultiAgent that adapts routing based on performance.

Init .

Parameters:
  • name (str) – [TODO: Add description]

  • agents (dict[str, Agent]) – [TODO: Add description]

get_best_agent_for_task(task_type='general')

Get best performing agent.

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_standalone.Agent(/, **data)

Bases: pydantic.BaseModel, abc.ABC

Enhanced Agent base class - Agent[EngineT] pattern.

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)

abstractmethod arun(input_data, debug=False)
Async:

Parameters:
Return type:

str

Async execution method.

run(input_data, debug=False)

Sync execution method.

Parameters:
Return type:

str

class agents.multi.enhanced_multi_agent_standalone.BranchingMultiAgent(name, agents, **kwargs)

Bases: MultiAgent[dict[str, Agent]]

MultiAgent specialized for branching execution.

Init .

Parameters:
  • name (str) – [TODO: Add description]

  • agents (dict[str, Agent]) – [TODO: Add description]

class agents.multi.enhanced_multi_agent_standalone.MinimalEngine(/, **data)

Bases: pydantic.BaseModel

Minimal engine for demonstration.

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.multi.enhanced_multi_agent_standalone.MultiAgent(/, **data)

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 engine for coordination) 2. Generic on the agents it contains

Examples

Sequential pipeline:

agents = [planner, executor, reviewer]
multi: MultiAgent[List[SimpleAgent]] = MultiAgent(
    name="pipeline",
    agents=agents,
    mode="sequential"
)

Branching router:

agents = {"technical": tech_agent, "business": biz_agent}
multi: MultiAgent[Dict[str, SimpleAgent]] = MultiAgent(
    name="router",
    agents=agents,
    mode="branch"
)

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)

async arun(input_data, debug=False)

Execute based on mode.

Parameters:
Return type:

str

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_standalone.SimpleAgent(/, **data)

Bases: Agent

SimpleAgent = Agent[AugLLMConfig] - minimal working implementation.

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)

async arun(input_data, debug=False)

Async run with realistic simulation.

Parameters:
Return type:

str

async agents.multi.enhanced_multi_agent_standalone.demo_enhanced_multi_agent()

Demonstrate all enhanced multi-agent patterns.