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¶
Branching MultiAgent that adapts routing based on performance. |
|
Enhanced Agent base class - Agent[EngineT] pattern. |
|
MultiAgent specialized for branching execution. |
|
Minimal engine for demonstration. |
|
Enhanced MultiAgent generic on the agents it contains. |
|
SimpleAgent = Agent[AugLLMConfig] - minimal working implementation. |
Functions¶
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:
- get_best_agent_for_task(task_type='general')¶
Get best performing agent.
- 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 execution method.
- class agents.multi.enhanced_multi_agent_standalone.BranchingMultiAgent(name, agents, **kwargs)¶
Bases:
MultiAgent
[dict
[str
,Agent
]]MultiAgent specialized for branching execution.
Init .
- 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.
- 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 agents.multi.enhanced_multi_agent_standalone.demo_enhanced_multi_agent()¶
Demonstrate all enhanced multi-agent patterns.