create_swarm_transition

create_swarm_transition(
    initial_agent: ConversableAgent,
    tool_execution: ConversableAgent,
    swarm_agent_names: list[str],
    user_agent: UserProxyAgent | None,
    swarm_after_work: AfterWorkOption | Callable[..., Any] | None
) -> Callable[[ConversableAgent, GroupChat], Agent | None]

Creates a transition function for swarm chat with enclosed state for the use_initial_agent.

Parameters:
NameDescription
initial_agentThe first agent to speak

Type: ConversableAgent
tool_executionThe tool execution agent

Type: ConversableAgent
swarm_agent_namesList of all agent names

Type: list[str]
user_agentOptional user proxy agent

Type: UserProxyAgent | None
swarm_after_workSwarm-level after work

Type: AfterWorkOption | Callable[…, Any] | None
Returns:
TypeDescription
Callable[[ConversableAgent, GroupChat], Agent | None]Callable transition function (for sync and async swarm chats)