autogen_agentchat.conditions#
This module provides various termination conditions for controlling the behavior of multi-agent teams.
- class ExternalTermination[source]#
- Bases: - TerminationCondition,- Component[- ExternalTerminationConfig]- A termination condition that is externally controlled by calling the - set()method.- Example: - from autogen_agentchat.conditions import ExternalTermination termination = ExternalTermination() # Run the team in an asyncio task. ... # Set the termination condition externally termination.set() - classmethod _from_config(config: ExternalTerminationConfig) Self[source]#
- Create a new instance of the component from a configuration object. - Parameters:
- config (T) – The configuration object. 
- Returns:
- Self – The new instance of the component. 
 
 - _to_config() ExternalTerminationConfig[source]#
- Dump the configuration that would be requite to create a new instance of a component matching the configuration of this instance. - Returns:
- T – The configuration of the component. 
 
 - component_config_schema#
- alias of - ExternalTerminationConfig
 
- class HandoffTermination(target: str)[source]#
- Bases: - TerminationCondition,- Component[- HandoffTerminationConfig]- Terminate the conversation if a - HandoffMessagewith the given target is received.- Parameters:
- target (str) – The target of the handoff message. 
 - classmethod _from_config(config: HandoffTerminationConfig) Self[source]#
- Create a new instance of the component from a configuration object. - Parameters:
- config (T) – The configuration object. 
- Returns:
- Self – The new instance of the component. 
 
 - _to_config() HandoffTerminationConfig[source]#
- Dump the configuration that would be requite to create a new instance of a component matching the configuration of this instance. - Returns:
- T – The configuration of the component. 
 
 - component_config_schema#
- alias of - HandoffTerminationConfig
 
- class MaxMessageTermination(max_messages: int)[source]#
- Bases: - TerminationCondition,- Component[- MaxMessageTerminationConfig]- Terminate the conversation after a maximum number of messages have been exchanged. - Parameters:
- max_messages – The maximum number of messages allowed in the conversation. 
 - classmethod _from_config(config: MaxMessageTerminationConfig) Self[source]#
- Create a new instance of the component from a configuration object. - Parameters:
- config (T) – The configuration object. 
- Returns:
- Self – The new instance of the component. 
 
 - _to_config() MaxMessageTerminationConfig[source]#
- Dump the configuration that would be requite to create a new instance of a component matching the configuration of this instance. - Returns:
- T – The configuration of the component. 
 
 - component_config_schema#
- alias of - MaxMessageTerminationConfig
 
- class SourceMatchTermination(sources: List[str])[source]#
- Bases: - TerminationCondition,- Component[- SourceMatchTerminationConfig]- Terminate the conversation after a specific source responds. - Parameters:
- sources (List[str]) – List of source names to terminate the conversation. 
- Raises:
- TerminatedException – If the termination condition has already been reached. 
 - classmethod _from_config(config: SourceMatchTerminationConfig) Self[source]#
- Create a new instance of the component from a configuration object. - Parameters:
- config (T) – The configuration object. 
- Returns:
- Self – The new instance of the component. 
 
 - _to_config() SourceMatchTerminationConfig[source]#
- Dump the configuration that would be requite to create a new instance of a component matching the configuration of this instance. - Returns:
- T – The configuration of the component. 
 
 - component_config_schema#
- alias of - SourceMatchTerminationConfig
 
- class StopMessageTermination[source]#
- Bases: - TerminationCondition,- Component[- StopMessageTerminationConfig]- Terminate the conversation if a StopMessage is received. - classmethod _from_config(config: StopMessageTerminationConfig) Self[source]#
- Create a new instance of the component from a configuration object. - Parameters:
- config (T) – The configuration object. 
- Returns:
- Self – The new instance of the component. 
 
 - _to_config() StopMessageTerminationConfig[source]#
- Dump the configuration that would be requite to create a new instance of a component matching the configuration of this instance. - Returns:
- T – The configuration of the component. 
 
 - component_config_schema#
- alias of - StopMessageTerminationConfig
 
- class TextMentionTermination(text: str, sources: Sequence[str] | None = None)[source]#
- Bases: - TerminationCondition,- Component[- TextMentionTerminationConfig]- Terminate the conversation if a specific text is mentioned. - Parameters:
- text – The text to look for in the messages. 
- sources – Check only messages of the specified agents for the text to look for. 
 
 - classmethod _from_config(config: TextMentionTerminationConfig) Self[source]#
- Create a new instance of the component from a configuration object. - Parameters:
- config (T) – The configuration object. 
- Returns:
- Self – The new instance of the component. 
 
 - _to_config() TextMentionTerminationConfig[source]#
- Dump the configuration that would be requite to create a new instance of a component matching the configuration of this instance. - Returns:
- T – The configuration of the component. 
 
 - component_config_schema#
- alias of - TextMentionTerminationConfig
 
- class TimeoutTermination(timeout_seconds: float)[source]#
- Bases: - TerminationCondition,- Component[- TimeoutTerminationConfig]- Terminate the conversation after a specified duration has passed. - Parameters:
- timeout_seconds – The maximum duration in seconds before terminating the conversation. 
 - classmethod _from_config(config: TimeoutTerminationConfig) Self[source]#
- Create a new instance of the component from a configuration object. - Parameters:
- config (T) – The configuration object. 
- Returns:
- Self – The new instance of the component. 
 
 - _to_config() TimeoutTerminationConfig[source]#
- Dump the configuration that would be requite to create a new instance of a component matching the configuration of this instance. - Returns:
- T – The configuration of the component. 
 
 - component_config_schema#
- alias of - TimeoutTerminationConfig
 
- class TokenUsageTermination(max_total_token: int | None = None, max_prompt_token: int | None = None, max_completion_token: int | None = None)[source]#
- Bases: - TerminationCondition,- Component[- TokenUsageTerminationConfig]- Terminate the conversation if a token usage limit is reached. - Parameters:
- max_total_token – The maximum total number of tokens allowed in the conversation. 
- max_prompt_token – The maximum number of prompt tokens allowed in the conversation. 
- max_completion_token – The maximum number of completion tokens allowed in the conversation. 
 
- Raises:
- ValueError – If none of max_total_token, max_prompt_token, or max_completion_token is provided. 
 - classmethod _from_config(config: TokenUsageTerminationConfig) Self[source]#
- Create a new instance of the component from a configuration object. - Parameters:
- config (T) – The configuration object. 
- Returns:
- Self – The new instance of the component. 
 
 - _to_config() TokenUsageTerminationConfig[source]#
- Dump the configuration that would be requite to create a new instance of a component matching the configuration of this instance. - Returns:
- T – The configuration of the component. 
 
 - component_config_schema#
- alias of - TokenUsageTerminationConfig