Skip to content

ExpressionAvailableCondition

autogen.agentchat.group.available_condition.ExpressionAvailableCondition #

Bases: AvailableCondition

Expression-based available condition.

This condition evaluates a ContextExpression against the context variables.

expression instance-attribute #

expression

is_available #

is_available(agent, messages)

Evaluate the expression against the context variables.

PARAMETER DESCRIPTION
agent

The agent with context variables

TYPE: ConversableAgent

messages

The conversation history (not used)

TYPE: list[dict[str, Any]]

RETURNS DESCRIPTION
bool

Boolean result of the expression evaluation

Source code in autogen/agentchat/group/available_condition.py
def is_available(self, agent: "ConversableAgent", messages: list[dict[str, Any]]) -> bool:
    """Evaluate the expression against the context variables.

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

    Returns:
        Boolean result of the expression evaluation
    """
    return self.expression.evaluate(agent.context_variables)