Pattern

Pattern(
    initial_agent: ConversableAgent,
    agents: list['ConversableAgent'],
    user_agent: ForwardRef('ConversableAgent') | None = None,
    group_manager_args: dict[str, Any] | None = None,
    context_variables: ContextVariables | None = None,
    group_after_work: TransitionTarget | None = None,
    exclude_transit_message: bool = True,
    summary_method: str | Callable[..., Any] | None = 'last_msg'
)

Base abstract class for all orchestration patterns.
Patterns provide a reusable way to define how agents interact within a group chat.
Each pattern encapsulates the logic for setting up agents, configuring handoffs, and determining the flow of conversation.
This is an abstract base class and should not be instantiated directly.
Use one of the concrete pattern implementations like AutoPattern, RoundRobinPattern, RandomPattern, or ManualPattern.
Initialize the pattern with the required components.

Parameters:
NameDescription
initial_agentType: ConversableAgent
agentsType: list[‘ConversableAgent’]
user_agentType: ForwardRef(‘ConversableAgent’) | None

Default: None
group_manager_argsType: dict[str, typing.Any] | None

Default: None
context_variablesType: ContextVariables | None

Default: None
group_after_workType: TransitionTarget | None

Default: None
exclude_transit_messageType: bool

Default: True
summary_methodType: str | Callable[…, Any] | None

Default: ‘last_msg’

Static Methods

create_default

create_default(
    initial_agent: ConversableAgent,
    agents: list['ConversableAgent'],
    user_agent: ForwardRef('ConversableAgent') | None = None,
    group_manager_args: dict[str, Any] | None = None,
    context_variables: ContextVariables | None = None,
    exclude_transit_message: bool = True,
    summary_method: str | Callable[..., Any] | None = 'last_msg'
) -> 

Create a default pattern with minimal configuration.
This replaces the need for a separate BasePattern class by providing a factory method that creates a simple DefaultPattern instance.

Parameters:
NameDescription
initial_agentThe first agent to speak in the group chat.

Type: ConversableAgent
agentsList of all agents participating in the chat.

Type: list[‘ConversableAgent’]
user_agentOptional user proxy agent.

Type: ForwardRef(‘ConversableAgent’) | None

Default: None
group_manager_argsOptional arguments for the GroupChatManager.

Type: dict[str, typing.Any] | None

Default: None
context_variablesInitial context variables for the chat.

Type: ContextVariables | None

Default: None
exclude_transit_messageWhether to exclude transit messages from the conversation.

Type: bool

Default: True
summary_methodMethod for summarizing the conversation.

Type: str | Callable[…, Any] | None

Default: ‘last_msg’

Instance Methods

prepare_group_chat

prepare_group_chat(
    self,
    max_rounds: int,
    messages: list[dict[str, Any]] | str
) -> Tuple[list['ConversableAgent'], list['ConversableAgent'], ConversableAgent | None, ContextVariables, ConversableAgent, TransitionTarget, GroupToolExecutor, GroupChat, GroupChatManager, list[dict[str, Any]], ConversableAgent, list[str], list['Agent']]

Prepare the group chat for orchestration.
This is the main method called by initiate_group_chat to set up the pattern.
Subclasses must implement or extend this method to define pattern-specific behavior.

Parameters:
NameDescription
max_roundsMaximum number of conversation rounds.

Type: int
messagesInitial message(s) to start the conversation.

Type: list[dict[str, typing.Any]] | str
Returns:
TypeDescription
Tuple[list[‘ConversableAgent’], list[‘ConversableAgent’], ConversableAgent | None, ContextVariables, ConversableAgent, TransitionTarget, GroupToolExecutor, GroupChat, GroupChatManager, list[dict[str, Any]], ConversableAgent, list[str], list[‘Agent’]]Tuple containing: - List of agents involved in the group chat - List of wrapped agents - User agent, if applicable - Context variables for the group chat - Initial agent for the group chat - Group-level after work transition for the group chat - Tool executor for the group chat - GroupChat instance - GroupChatManager instance - Processed messages - Last agent to speak - List of group agent names - List of temporary user agents