From 8404ff353781a07b88d6885289d4e47bb0bb5425 Mon Sep 17 00:00:00 2001 From: Yiran Wu <32823396+kevin666aa@users.noreply.github.com> Date: Sun, 17 Nov 2024 18:56:59 -0500 Subject: [PATCH] update --- autogen/agentchat/contrib/swarm_agent.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/autogen/agentchat/contrib/swarm_agent.py b/autogen/agentchat/contrib/swarm_agent.py index d31866cc9d..9bf083c28a 100644 --- a/autogen/agentchat/contrib/swarm_agent.py +++ b/autogen/agentchat/contrib/swarm_agent.py @@ -68,10 +68,11 @@ def swarm_transition(last_speaker: SwarmAgent, groupchat: GroupChat): manager = GroupChatManager(groupchat) clear_history = True - if messages > 1: + if len(messages) > 1: last_agent, last_message = manager.resume(messages=messages) clear_history = False else: + last_message = messages[0] last_agent = init_agent chat_history = last_agent.initiate_chat( @@ -202,15 +203,14 @@ def generate_swarm_tool_reply( # 3. update context_variables and next_agent, convert content to string for tool_response in tool_message["tool_responses"]: - if tool_response["type"] == "function": - content = tool_response.get("content") - if isinstance(content, SwarmResult): - if content.context_variables != {}: - self.context_variables.update(content.context_variables) - if content.agent is not None: - self.next_agent = content.agent - elif isinstance(content, Agent): - self.next_agent = content + content = tool_response.get("content") + if isinstance(content, SwarmResult): + if content.context_variables != {}: + self.context_variables.update(content.context_variables) + if content.agent is not None: + self.next_agent = content.agent + elif isinstance(content, Agent): + self.next_agent = content tool_response["content"] = str(tool_response["content"]) return True, tool_message