Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
yiranwu0 committed Nov 17, 2024
1 parent 4d58d6a commit 8404ff3
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions autogen/agentchat/contrib/swarm_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8404ff3

Please sign in to comment.