ON_CONDITION

ON_CONDITION(
    target: ForwardRef('SwarmAgent') | dict[str, typing.Any] = None,
    condition: str = '',
    available: str | Callable | None = None
)

Defines a condition for transitioning to another agent or nested chats

Parameters:
NameDescription
targetThe agent to hand off to or the nested chat configuration.

Can be a SwarmAgent or a Dict.

If a Dict, it should follow the convention of the nested chat configuration, with the exception of a carryover configuration which is unique to Swarms.

Swarm Nested chat documentation: https://docs.ag2.ai/docs/topics/swarm#registering-handoffs-to-a-nested-chat

Type: ForwardRef('SwarmAgent') | dict[str, typing.Any]

Default: None
conditionThe condition for transitioning to the target agent, evaluated by the LLM to determine whether to call the underlying function/tool which does the transition.

Type: str

Default:
availableOptional condition to determine if this ON_CONDITION is available.

Can be a Callable or a string.

If a string, it will look up the value of the context variable with that name, which should be a bool.

Type: str | Callable | None

Default: None

Class Attributes

available



condition



target