Skip to content

StringAvailableCondition

autogen.agentchat.group.available_condition.StringAvailableCondition #

Bases: AvailableCondition

String-based available condition.

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

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))