Skip to content

TransitionTarget

autogen.agentchat.group.targets.transition_target.TransitionTarget #

Bases: BaseModel

Base class for all transition targets across OnCondition, OnContextCondition, and after work.

can_resolve_for_speaker_selection #

can_resolve_for_speaker_selection()

Check if the target can resolve to an option for speaker selection (Agent, 'None' to end, Str for speaker selection method). In the case of a nested chat, this will return False as it should be encapsulated in an agent.

Source code in autogen/agentchat/group/targets/transition_target.py
def can_resolve_for_speaker_selection(self) -> bool:
    """Check if the target can resolve to an option for speaker selection (Agent, 'None' to end, Str for speaker selection method). In the case of a nested chat, this will return False as it should be encapsulated in an agent."""
    return False

resolve #

resolve(groupchat, current_agent, user_agent)

Resolve to a speaker selection result (Agent, None for termination, or str for speaker selection method).

Source code in autogen/agentchat/group/targets/transition_target.py
def resolve(
    self,
    groupchat: "GroupChat",
    current_agent: "ConversableAgent",
    user_agent: Optional["ConversableAgent"],
) -> SpeakerSelectionResult:
    """Resolve to a speaker selection result (Agent, None for termination, or str for speaker selection method)."""
    raise NotImplementedError("Requires subclasses to implement.")

display_name #

display_name()

Get the display name for the target.

Source code in autogen/agentchat/group/targets/transition_target.py
def display_name(self) -> str:
    """Get the display name for the target."""
    raise NotImplementedError("Requires subclasses to implement.")

normalized_name #

normalized_name()

Get a normalized name for the target that has no spaces, used for function calling

Source code in autogen/agentchat/group/targets/transition_target.py
def normalized_name(self) -> str:
    """Get a normalized name for the target that has no spaces, used for function calling"""
    raise NotImplementedError("Requires subclasses to implement.")

needs_agent_wrapper #

needs_agent_wrapper()

Check if the target needs to be wrapped in an agent.

Source code in autogen/agentchat/group/targets/transition_target.py
def needs_agent_wrapper(self) -> bool:
    """Check if the target needs to be wrapped in an agent."""
    raise NotImplementedError("Requires subclasses to implement.")

create_wrapper_agent #

create_wrapper_agent(parent_agent, index)

Create a wrapper agent for the target if needed.

Source code in autogen/agentchat/group/targets/transition_target.py
def create_wrapper_agent(self, parent_agent: "ConversableAgent", index: int) -> "ConversableAgent":
    """Create a wrapper agent for the target if needed."""
    raise NotImplementedError("Requires subclasses to implement.")

activate_target #

activate_target(groupchat)

Activate the target in the groupchat, setting the next target for GroupToolExecutor.

The Tool Executor's next target attribute will be picked up on the next iteration when _determine_next_agent is called

Source code in autogen/agentchat/group/targets/transition_target.py
def activate_target(self, groupchat: "GroupChat") -> None:
    """Activate the target in the groupchat, setting the next target for GroupToolExecutor.

    The Tool Executor's next target attribute will be picked up on the next iteration when _determine_next_agent is called"""
    for agent in groupchat.agents:  # type: ignore[attr-defined]
        # get the GroupToolExecutor agent
        if type(agent).__name__ == "GroupToolExecutor":
            agent.set_next_target(self)  # type: ignore[attr-defined]
            return