Handoffs
autogen.agentchat.group.handoffs.Handoffs #
Bases: BaseModel
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)
context_conditions class-attribute instance-attribute #
context_conditions = Field(default_factory=list)
add_context_condition #
Add a single context condition.
| PARAMETER | DESCRIPTION |
|---|---|
condition | The OnContextCondition to add TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Handoffs | Self for method chaining |
Source code in autogen/agentchat/group/handoffs.py
add_context_conditions #
Add multiple context conditions.
| PARAMETER | DESCRIPTION |
|---|---|
conditions | List of OnContextConditions to add TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Handoffs | Self for method chaining |
Source code in autogen/agentchat/group/handoffs.py
add_llm_condition #
Add a single LLM condition.
| PARAMETER | DESCRIPTION |
|---|---|
condition | The OnCondition to add TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Handoffs | Self for method chaining |
Source code in autogen/agentchat/group/handoffs.py
add_llm_conditions #
Add multiple LLM conditions.
| PARAMETER | DESCRIPTION |
|---|---|
conditions | List of OnConditions to add TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Handoffs | Self for method chaining |
Source code in autogen/agentchat/group/handoffs.py
set_after_work #
Set the after work target (only one allowed).
| PARAMETER | DESCRIPTION |
|---|---|
target | The after work TransitionTarget to set TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
Handoffs | Self for method chaining |
Source code in autogen/agentchat/group/handoffs.py
add #
add(condition: OnContextCondition) -> Handoffs
add(condition: OnCondition) -> Handoffs
Add a single condition (OnContextCondition or OnCondition).
| PARAMETER | DESCRIPTION |
|---|---|
condition | The condition to add (OnContextCondition or OnCondition) TYPE: |
| RAISES | DESCRIPTION |
|---|---|
TypeError | If the condition type is not supported |
| RETURNS | DESCRIPTION |
|---|---|
Handoffs | Self for method chaining |
Source code in autogen/agentchat/group/handoffs.py
add_many #
Add multiple conditions of any supported types (OnContextCondition and OnCondition).
| PARAMETER | DESCRIPTION |
|---|---|
conditions | List of conditions to add TYPE: |
| RAISES | DESCRIPTION |
|---|---|
TypeError | If an unsupported condition type is provided |
| RETURNS | DESCRIPTION |
|---|---|
Handoffs | Self for method chaining |
Source code in autogen/agentchat/group/handoffs.py
get_llm_conditions_by_target_type #
Get OnConditions for a specific target type.
| PARAMETER | DESCRIPTION |
|---|---|
target_type | The type of condition to retrieve TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
list[OnCondition] | List of conditions of the specified type, or None if none exist |
Source code in autogen/agentchat/group/handoffs.py
get_context_conditions_by_target_type #
Get OnContextConditions for a specific target type.
| PARAMETER | DESCRIPTION |
|---|---|
target_type | The type of condition to retrieve TYPE: |
| RETURNS | DESCRIPTION |
|---|---|
list[OnContextCondition] | List of conditions of the specified type, or None if none exist |
Source code in autogen/agentchat/group/handoffs.py
get_llm_conditions_requiring_wrapping #
Get LLM conditions that have targets that require wrapping.
| RETURNS | DESCRIPTION |
|---|---|
list[OnCondition] | List of LLM conditions that require wrapping |
Source code in autogen/agentchat/group/handoffs.py
get_context_conditions_requiring_wrapping #
Get context conditions that have targets that require wrapping.
| RETURNS | DESCRIPTION |
|---|---|
list[OnContextCondition] | List of context conditions that require wrapping |
Source code in autogen/agentchat/group/handoffs.py
set_llm_function_names #
Set the LLM function names for all LLM conditions, creating unique names for each function.