> ## 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.Handoffs

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

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

```python theme={null}
Handoffs(**data: Any)
```

Container for all handoff transition conditions of a ConversableAgent.<br />Three types of conditions can be added, each with a different order and time of use: <br />1. OnContextConditions (evaluated without an LLM)
2\. OnConditions (evaluated with an LLM)
3\. After work TransitionTarget (if no other transition is triggered)

Supports method chaining: <br />agent.handoffs.add\_context\_conditions(\[condition1])                    .add\_llm\_condition(condition2)                    .set\_after\_work(after\_work)

Create a new model by parsing and validating input data from keyword arguments.<br />Raises \[`ValidationError`]\[pydantic\_core.ValidationError] if the input data cannot be
validated to form a valid model.<br />`self` is explicitly positional-only to allow `self` as a field name.

<b>Parameters:</b>

| Name     | Description   |
| -------- | ------------- |
| `**data` | **Type:** Any |

### Class Attributes

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

#### after\_work

<br />

<br />

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

#### context\_conditions

<br />

<br />

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

#### llm\_conditions

<br />

<br />

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

#### model\_config

<br />

<br />

### Instance Methods

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

#### add

```python theme={null}
add(self, condition: OnContextCondition | OnCondition) -> Handoffs
```

Add a single condition (OnContextCondition or OnCondition).<br />

<b>Parameters:</b>

| Name        | Description                                                                                                                                                                                                                                       |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `condition` | The condition to add (OnContextCondition or OnCondition)<br /><br />**Type:** [OnContextCondition](/docs/api-reference/autogen/agentchat/group/on_context_condition/OnContextCondition) \| [OnCondition](/docs/api-reference/autogen/OnCondition) |

<b>Returns:</b>

| Type                                                                      | Description              |
| ------------------------------------------------------------------------- | ------------------------ |
| [Handoffs](/docs/api-reference/autogen/agentchat/group/handoffs/Handoffs) | Self for method chaining |

<br />

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

#### add\_context\_condition

```python theme={null}
add_context_condition(self, condition: OnContextCondition) -> Handoffs
```

Add a single context condition.<br />

<b>Parameters:</b>

| Name        | Description                                                                                                                                                  |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `condition` | The OnContextCondition to add<br /><br />**Type:** [OnContextCondition](/docs/api-reference/autogen/agentchat/group/on_context_condition/OnContextCondition) |

<b>Returns:</b>

| Type                                                                      | Description              |
| ------------------------------------------------------------------------- | ------------------------ |
| [Handoffs](/docs/api-reference/autogen/agentchat/group/handoffs/Handoffs) | Self for method chaining |

<br />

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

#### add\_context\_conditions

```python theme={null}
add_context_conditions(self, conditions: list[OnContextCondition]) -> Handoffs
```

Add multiple context conditions.<br />

<b>Parameters:</b>

| Name         | Description                                                                                                                                                              |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `conditions` | List of OnContextConditions to add<br /><br />**Type:** list\[[OnContextCondition](/docs/api-reference/autogen/agentchat/group/on_context_condition/OnContextCondition)] |

<b>Returns:</b>

| Type                                                                      | Description              |
| ------------------------------------------------------------------------- | ------------------------ |
| [Handoffs](/docs/api-reference/autogen/agentchat/group/handoffs/Handoffs) | Self for method chaining |

<br />

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

#### add\_llm\_condition

```python theme={null}
add_llm_condition(self, condition: OnCondition) -> Handoffs
```

Add a single LLM condition.<br />

<b>Parameters:</b>

| Name        | Description                                                                                        |
| ----------- | -------------------------------------------------------------------------------------------------- |
| `condition` | The OnCondition to add<br /><br />**Type:** [OnCondition](/docs/api-reference/autogen/OnCondition) |

<b>Returns:</b>

| Type                                                                      | Description              |
| ------------------------------------------------------------------------- | ------------------------ |
| [Handoffs](/docs/api-reference/autogen/agentchat/group/handoffs/Handoffs) | Self for method chaining |

<br />

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

#### add\_llm\_conditions

```python theme={null}
add_llm_conditions(self, conditions: list[OnCondition]) -> Handoffs
```

Add multiple LLM conditions.<br />

<b>Parameters:</b>

| Name         | Description                                                                                                    |
| ------------ | -------------------------------------------------------------------------------------------------------------- |
| `conditions` | List of OnConditions to add<br /><br />**Type:** list\[[OnCondition](/docs/api-reference/autogen/OnCondition)] |

<b>Returns:</b>

| Type                                                                      | Description              |
| ------------------------------------------------------------------------- | ------------------------ |
| [Handoffs](/docs/api-reference/autogen/agentchat/group/handoffs/Handoffs) | Self for method chaining |

<br />

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

#### add\_many

```python theme={null}
add_many(self, conditions: list[OnContextCondition | OnCondition]) -> Handoffs
```

Add multiple conditions of any supported types (OnContextCondition and OnCondition).<br />

<b>Parameters:</b>

| Name         | Description                                                                                                                                                                                                               |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `conditions` | List of conditions to add<br /><br />**Type:** list\[[OnContextCondition](/docs/api-reference/autogen/agentchat/group/on_context_condition/OnContextCondition) \| [OnCondition](/docs/api-reference/autogen/OnCondition)] |

<b>Returns:</b>

| Type                                                                      | Description              |
| ------------------------------------------------------------------------- | ------------------------ |
| [Handoffs](/docs/api-reference/autogen/agentchat/group/handoffs/Handoffs) | Self for method chaining |

<br />

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

#### clear

```python theme={null}
clear(self) -> Handoffs
```

Clear all handoff conditions.<br />Returns: <br />    Self for method chaining

<b>Returns:</b>

| Type                                                                      | Description              |
| ------------------------------------------------------------------------- | ------------------------ |
| [Handoffs](/docs/api-reference/autogen/agentchat/group/handoffs/Handoffs) | Self for method chaining |

<br />

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

#### get\_context\_conditions\_by\_target\_type

```python theme={null}
get_context_conditions_by_target_type(self, target_type: type) -> list[OnContextCondition]
```

Get OnContextConditions for a specific target type.<br />

<b>Parameters:</b>

| Name          | Description                                                 |
| ------------- | ----------------------------------------------------------- |
| `target_type` | The type of condition to retrieve<br /><br />**Type:** type |

<b>Returns:</b>

| Type                                                                                                             | Description                                                     |
| ---------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- |
| list\[[OnContextCondition](/docs/api-reference/autogen/agentchat/group/on_context_condition/OnContextCondition)] | List of conditions of the specified type, or None if none exist |

<br />

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

#### get\_context\_conditions\_requiring\_wrapping

```python theme={null}
get_context_conditions_requiring_wrapping(self) -> list[OnContextCondition]
```

Get context conditions that have targets that require wrapping.<br />Returns: <br />    List of context conditions that require wrapping

<b>Returns:</b>

| Type                                                                                                             | Description                                      |
| ---------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| list\[[OnContextCondition](/docs/api-reference/autogen/agentchat/group/on_context_condition/OnContextCondition)] | List of context conditions that require wrapping |

<br />

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

#### get\_llm\_conditions\_by\_target\_type

```python theme={null}
get_llm_conditions_by_target_type(self, target_type: type) -> list[OnCondition]
```

Get OnConditions for a specific target type.<br />

<b>Parameters:</b>

| Name          | Description                                                 |
| ------------- | ----------------------------------------------------------- |
| `target_type` | The type of condition to retrieve<br /><br />**Type:** type |

<b>Returns:</b>

| Type                                                          | Description                                                     |
| ------------------------------------------------------------- | --------------------------------------------------------------- |
| list\[[OnCondition](/docs/api-reference/autogen/OnCondition)] | List of conditions of the specified type, or None if none exist |

<br />

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

#### get\_llm\_conditions\_requiring\_wrapping

```python theme={null}
get_llm_conditions_requiring_wrapping(self) -> list[OnCondition]
```

Get LLM conditions that have targets that require wrapping.<br />Returns: <br />    List of LLM conditions that require wrapping

<b>Returns:</b>

| Type                                                          | Description                                  |
| ------------------------------------------------------------- | -------------------------------------------- |
| list\[[OnCondition](/docs/api-reference/autogen/OnCondition)] | List of LLM conditions that require wrapping |

<br />

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

#### set\_after\_work

```python theme={null}
set_after_work(self, target: TransitionTarget) -> Handoffs
```

Set the after work target (only one allowed).<br />

<b>Parameters:</b>

| Name     | Description                                                                                                                                                            |
| -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `target` | The after work TransitionTarget to set<br /><br />**Type:** [TransitionTarget](/docs/api-reference/autogen/agentchat/group/targets/transition_target/TransitionTarget) |

<b>Returns:</b>

| Type                                                                      | Description              |
| ------------------------------------------------------------------------- | ------------------------ |
| [Handoffs](/docs/api-reference/autogen/agentchat/group/handoffs/Handoffs) | Self for method chaining |

<br />

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

#### set\_llm\_function\_names

```python theme={null}
set_llm_function_names(self) -> None
```

Set the LLM function names for all LLM conditions, creating unique names for each function.

<br />
