Skip to content

StringAvailableCondition

autogen.agentchat.group.available_condition.StringAvailableCondition #

StringAvailableCondition(context_variable, **data)

Bases: AvailableCondition

String-based available condition.

This condition checks if a named context variable exists and is truthy.

Initialize with a context variable name as a positional parameter.

PARAMETER DESCRIPTION
context_variable

The name of the context variable to check

TYPE: str

data

Additional data for the parent class

TYPE: Any DEFAULT: {}

Source code in autogen/agentchat/group/available_condition.py
def __init__(self, context_variable: str, **data: Any) -> None:
    """Initialize with a context variable name as a positional parameter.

    Args:
        context_variable: The name of the context variable to check
        data: Additional data for the parent class
    """
    super().__init__(context_variable=context_variable, **data)

context_variable instance-attribute #

context_variable

is_available #

is_available(agent, messages)

Check if the named context variable is truthy.

PARAMETER DESCRIPTION
agent

The agent with context variables

TYPE: ConversableAgent

messages

The conversation history (not used)

TYPE: list[dict[str, Any]]

RETURNS DESCRIPTION
bool

True if the variable exists and is truthy, False otherwise

Source code in autogen/agentchat/group/available_condition.py
def is_available(self, agent: "ConversableAgent", messages: list[dict[str, Any]]) -> bool:
    """Check if the named context variable is truthy.

    Args:
        agent: The agent with context variables
        messages: The conversation history (not used)

    Returns:
        True if the variable exists and is truthy, False otherwise
    """
    return bool(agent.context_variables.get(self.context_variable, False))