Iragent
This project is about using agents as simple as possible with small and large language models
Loading...
Searching...
No Matches
iragent.models.AutoAgentManager Class Reference

Public Member Functions

None __init__ (self, str init_message, List[Agent] agents, Agent first_agent, int max_round=3, Callable termination_fn=None, str termination_word=None)
 
Message start (self, message=None)
 

Public Attributes

 auto_agent
 
 first_agent = first_agent
 
 termination_fn = termination_fn
 
 max_round = max_round
 
dict agents = {agent.name: agent for agent in agents}
 
 init_msg
 
 termination_word = termination_word
 

Detailed Description

A multi-agent orchestration manager that routes messages between agents 
in an automated workflow, with support for termination conditions and 
dynamic agent selection.

This class coordinates the execution of multiple agents in a round-based 
loop. It starts with an initial message sent to the first agent, then uses 
an internal `agent_manager` to determine the next agent to route the 
response to. The process continues until:
    - The termination function returns True, or
    - The maximum number of rounds is reached.

Attributes:
    auto_agent (Agent): An internal controller agent responsible for 
        deciding which agent should handle the next step.
    first_agent (Agent): The first agent to receive the initial message.
    termination_fn (Callable): Optional function to determine when the 
        workflow should stop.
    max_round (int): Maximum number of message-passing iterations allowed.
    agents (dict[str, Agent]): Dictionary of available agents, keyed by 
        agent name.
    init_msg (Message): The initial message passed to the first agent.
    termination_word (str): Optional keyword used by `termination_fn` to 
        detect completion.

Args:
    init_message (str): The initial request or instruction from the user.
    agents (List[Agent]): The list of agents participating in the workflow.
    first_agent (Agent): The starting agent for message routing.
    max_round (int, optional): Maximum number of routing rounds. Defaults to 3.
    termination_fn (Callable, optional): A function to check if the process 
        should terminate early. Defaults to None.
    termination_word (str, optional): Keyword used in termination checks. 
        Defaults to None.

Methods:
    start(message: str = None) -> Message:
        Executes the multi-agent workflow starting from either the 
        `init_message` or a provided `message`.  
        The process:
            - Sends the message to the current agent.
            - Evaluates termination conditions after each response.
            - Uses `auto_agent` to determine the next agent in the sequence.
            - Stops when the termination function returns True or the 
              maximum round count is reached.
        Returns the final `Message` from the last executed agent.

Constructor & Destructor Documentation

◆ __init__()

None iragent.models.AutoAgentManager.__init__ ( self,
str init_message,
List[Agent] agents,
Agent first_agent,
int max_round = 3,
Callable termination_fn = None,
str termination_word = None )

Member Function Documentation

◆ start()

Message iragent.models.AutoAgentManager.start ( self,
message = None )

Member Data Documentation

◆ agents

dict iragent.models.AutoAgentManager.agents = {agent.name: agent for agent in agents}

◆ auto_agent

iragent.models.AutoAgentManager.auto_agent
Initial value:
= Agent(
"agent_manager",
system_prompt="You are the agent manager.",
model=first_agent.model,
base_url=first_agent.base_url,
api_key=first_agent.api_key,
temprature=0.1,
max_token=1024,
memory=BaseMemory
)

◆ first_agent

iragent.models.AutoAgentManager.first_agent = first_agent

◆ init_msg

iragent.models.AutoAgentManager.init_msg
Initial value:
= Message(
sender="user",
reciever=first_agent.name,
content=init_message,
intent="User request",
metadata={},
)

◆ max_round

iragent.models.AutoAgentManager.max_round = max_round

◆ termination_fn

iragent.models.AutoAgentManager.termination_fn = termination_fn

◆ termination_word

iragent.models.AutoAgentManager.termination_word = termination_word

The documentation for this class was generated from the following file: