autogen.agentchat.group.handoffs.Handoffs
Handoffs
Container for all handoff transition conditions of a ConversableAgent.
Three types of conditions can be added, each with a different order and time of use:
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:
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.
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.
Name | Description |
---|---|
**data | Type: Any |
Class Attributes
after_work
context_conditions
llm_conditions
model_config
Instance Methods
add
Add a single condition (OnContextCondition or OnCondition).
Name | Description |
---|---|
condition | The condition to add (OnContextCondition or OnCondition) Type: OnContextCondition | OnCondition |
Type | Description |
---|---|
Handoffs | Self for method chaining |
add_context_condition
Add a single context condition.
Name | Description |
---|---|
condition | The OnContextCondition to add Type: OnContextCondition |
Type | Description |
---|---|
Handoffs | Self for method chaining |
add_context_conditions
Add multiple context conditions.
Name | Description |
---|---|
conditions | List of OnContextConditions to add Type: list[OnContextCondition] |
Type | Description |
---|---|
Handoffs | Self for method chaining |
add_llm_condition
Add a single LLM condition.
Name | Description |
---|---|
condition | The OnCondition to add Type: OnCondition |
Type | Description |
---|---|
Handoffs | Self for method chaining |
add_llm_conditions
Add multiple LLM conditions.
Name | Description |
---|---|
conditions | List of OnConditions to add Type: list[OnCondition] |
Type | Description |
---|---|
Handoffs | Self for method chaining |
add_many
Add multiple conditions of any supported types (OnContextCondition and OnCondition).
Name | Description |
---|---|
conditions | List of conditions to add Type: list[OnContextCondition | OnCondition] |
Type | Description |
---|---|
Handoffs | Self for method chaining |
clear
Clear all handoff conditions.
Returns:
Self for method chaining
Type | Description |
---|---|
Handoffs | Self for method chaining |
get_context_conditions_by_target_type
Get OnContextConditions for a specific target type.
Name | Description |
---|---|
target_type | The type of condition to retrieve Type: type |
Type | Description |
---|---|
list[OnContextCondition] | List of conditions of the specified type, or None if none exist |
get_context_conditions_requiring_wrapping
Get context conditions that have targets that require wrapping.
Returns:
List of context conditions that require wrapping
Type | Description |
---|---|
list[OnContextCondition] | List of context conditions that require wrapping |
get_llm_conditions_by_target_type
Get OnConditions for a specific target type.
Name | Description |
---|---|
target_type | The type of condition to retrieve Type: type |
Type | Description |
---|---|
list[OnCondition] | List of conditions of the specified type, or None if none exist |
get_llm_conditions_requiring_wrapping
Get LLM conditions that have targets that require wrapping.
Returns:
List of LLM conditions that require wrapping
Type | Description |
---|---|
list[OnCondition] | List of LLM conditions that require wrapping |
set_after_work
Set the after work target (only one allowed).
Name | Description |
---|---|
target | The after work TransitionTarget to set Type: TransitionTarget |
Type | Description |
---|---|
Handoffs | Self for method chaining |
set_llm_function_names
Set the LLM function names for all LLM conditions, creating unique names for each function.