> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ag2.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# autogen.agentchat.group.patterns.pattern.Pattern

<h2 id="autogen.agentchat.group.patterns.pattern.Pattern" class="doc doc-heading">
  <code class="doc-symbol doc-symbol-heading doc-symbol-class" />

  <span class="doc doc-object-name doc-class-name">Pattern</span>
</h2>

```python theme={null}
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.<br />Patterns provide a reusable way to define how agents interact within a group chat.<br />Each pattern encapsulates the logic for setting up agents, configuring handoffs,
and determining the flow of conversation.<br />This is an abstract base class and should not be instantiated directly.<br />Use one of the concrete pattern implementations like AutoPattern,
RoundRobinPattern, RandomPattern, or ManualPattern.<br />Initialize the pattern with the required components.<br />

<b>Parameters:</b>

| Name                      | Description                                                                                                                                               |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initial_agent`           | **Type:** ConversableAgent                                                                                                                                |
| `agents`                  | **Type:** list\['ConversableAgent']                                                                                                                       |
| `user_agent`              | **Type:** ForwardRef('ConversableAgent') \| None<br /><br />**Default:** None                                                                             |
| `group_manager_args`      | **Type:** dict\[str, typing.Any] \| None<br /><br />**Default:** None                                                                                     |
| `context_variables`       | **Type:** [ContextVariables](/docs/api-reference/autogen/agentchat/group/context_variables/ContextVariables) \| None<br /><br />**Default:** None         |
| `group_after_work`        | **Type:** [TransitionTarget](/docs/api-reference/autogen/agentchat/group/targets/transition_target/TransitionTarget) \| None<br /><br />**Default:** None |
| `exclude_transit_message` | **Type:** bool<br /><br />**Default:** True                                                                                                               |
| `summary_method`          | **Type:** str \| Callable\[..., Any] \| None<br /><br />**Default:** 'last\_msg'                                                                          |

### Static Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### create\_default

```python theme={null}
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.<br />This replaces the need for a separate BasePattern class by providing
a factory method that creates a simple DefaultPattern instance.<br />

<b>Parameters:</b>

| Name                      | Description                                                                                                                                                                                          |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `initial_agent`           | The first agent to speak in the group chat.<br /><br />**Type:** ConversableAgent                                                                                                                    |
| `agents`                  | List of all agents participating in the chat.<br /><br />**Type:** list\['ConversableAgent']                                                                                                         |
| `user_agent`              | Optional user proxy agent.<br /><br />**Type:** ForwardRef('ConversableAgent') \| None<br /><br />**Default:** None                                                                                  |
| `group_manager_args`      | Optional arguments for the GroupChatManager.<br /><br />**Type:** dict\[str, typing.Any] \| None<br /><br />**Default:** None                                                                        |
| `context_variables`       | Initial context variables for the chat.<br /><br />**Type:** [ContextVariables](/docs/api-reference/autogen/agentchat/group/context_variables/ContextVariables) \| None<br /><br />**Default:** None |
| `exclude_transit_message` | Whether to exclude transit messages from the conversation.<br /><br />**Type:** bool<br /><br />**Default:** True                                                                                    |
| `summary_method`          | Method for summarizing the conversation.<br /><br />**Type:** str \| Callable\[..., Any] \| None<br /><br />**Default:** 'last\_msg'                                                                 |

<br />

### Instance Methods

<code class="doc-symbol doc-symbol-heading doc-symbol-method" />

#### prepare\_group\_chat

```python theme={null}
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.<br />This is the main method called by initiate\_group\_chat to set up the pattern.<br />Subclasses must implement or extend this method to define pattern-specific behavior.<br />

<b>Parameters:</b>

| Name         | Description                                                                                             |
| ------------ | ------------------------------------------------------------------------------------------------------- |
| `max_rounds` | Maximum number of conversation rounds.<br /><br />**Type:** int                                         |
| `messages`   | Initial message(s) to start the conversation.<br /><br />**Type:** list\[dict\[str, typing.Any]] \| str |

<b>Returns:</b>

| Type                                                                                                                                                                                                                                                                                                                                                                                                                                           | Description                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Tuple\[list\['ConversableAgent'], list\['ConversableAgent'], ConversableAgent \| None, [ContextVariables](/docs/api-reference/autogen/agentchat/group/context_variables/ContextVariables), ConversableAgent, [TransitionTarget](/docs/api-reference/autogen/agentchat/group/targets/transition_target/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 |

<br />
