Skip to main content

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.
Parameters:

Class Attributes

after_work



context_conditions



llm_conditions



model_config



Instance Methods

add

Add a single condition (OnContextCondition or OnCondition).
Parameters: Returns:

add_context_condition

Add a single context condition.
Parameters: Returns:

add_context_conditions

Add multiple context conditions.
Parameters: Returns:

add_llm_condition

Add a single LLM condition.
Parameters: Returns:

add_llm_conditions

Add multiple LLM conditions.
Parameters: Returns:

add_many

Add multiple conditions of any supported types (OnContextCondition and OnCondition).
Parameters: Returns:

clear

Clear all handoff conditions.
Returns:
Self for method chaining
Returns:

get_context_conditions_by_target_type

Get OnContextConditions for a specific target type.
Parameters: Returns:

get_context_conditions_requiring_wrapping

Get context conditions that have targets that require wrapping.
Returns:
List of context conditions that require wrapping
Returns:

get_llm_conditions_by_target_type

Get OnConditions for a specific target type.
Parameters: Returns:

get_llm_conditions_requiring_wrapping

Get LLM conditions that have targets that require wrapping.
Returns:
List of LLM conditions that require wrapping
Returns:

set_after_work

Set the after work target (only one allowed).
Parameters: Returns:

set_llm_function_names

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