0.8.7
version of the documentation here.autogen
module (and shouldn’t be used for the new group chat):
AFTER_WORK
AfterWork
AfterWorkOption
initiate_swarm_chat
ON_CONDITION
OnCondition
OnContextCondition
register_hand_off
SwarmAgent
SwarmResult
autogen.agentchat.contrib.swarm_agent
:
ContextExpression
and ContextStr
, these are available to import from the new group module:
ConversableAgent
s in the swarm) were a dictionary (type: dict[str, Any]
). This has now been put into a dedicated class called ContextVariables
. When interacting with your context variables, this still appears as a dictionary.
To use the context variables on an agent instance, access them via the agent’s context_variable
attribute, e.g. triage_agent.context_variables.get("my_key")
.
The changes you will need to make are to (1) change the import location and (2) change your type references from dict[str, Any]
to ContextVariables
.
autogen.agentchat.contrib.swarm_agent
as there are a few classes that have the same name.
The new group chat classes can be imported from autogen.agentchat.group
(primary), as well as autogen.agentchat.group.patterns
and autogen.agentchat.group.targets
.
For example:
dict[str, Any]
type, they use a new class called ContextVariables
. You can continue to interact with context variables like it is a dictionary.
The changes you will need to make are to (1) change the import location and (2) change your type references from dict[str, Any]
to ContextVariables
.
ReplyResult
instead of a SwarmResult
.
A new concept introduced here is a Transition Target
, which is what AG2 will transition to next. In a swarm you could transition to an agent by passing in the agent or the name of the agent, alternatively you could transition to an AfterWorkOption
such as to terminate or revert to the user. In the new group chat all the possible transitions are Targets
, such as AgentTarget
, AgentNameTarget
, and TerminateTarget
.
register_hand_off
).
Handoffs have been split into LLM conditions (OnCondition
), context variable based conditions (OnContextCondition
), and the after work. You will generally be setting these separately.
New classes have been introduced for use with the condition
and the available
parameters to ensure compliance while giving flexibility to introduce new classes without changing the fundamental group chat mechanism.
For LLM-based conditions
initiate_group_chat
.
To replicate the current swarm, you can use the base Pattern
class and the parameters and types are largely the same as those of initiate_swarm_chat
.