[Bug]:
Describe the bug
When running a group chat with AssistantAgents and GPTAssistantAgent, it throws AttributeError: 'NoneType' object has no attribute 'strip' when trying to agent.description.strip() == "":
for agent in agents:
if agent.description.strip() == "":
logger.warning(
f"The agent '{agent.name}' has an empty description, and may not work well with GroupChat."
)
roles.append(f"{agent.name}: {agent.description}".strip())
Steps to reproduce
Step 1: Initialize GPTAssistantAgent using id
Step 2: Create other autogen.AssistantAgents
Step 3: Create custom_speaker_selection_func
def custom_speaker_selection_func(last_speaker: Agent, groupchat: autogen.GroupChat):
"""Define a customized speaker selection function."""
messages = groupchat.messages
if len(messages) <= 1:
return planner
elif last_speaker is planner:
if messages[-1]["content"].strip() != "":
# Pass it to the researcher to carry out the research for the content
return researcher
else:
# If the planner's message is empty, let the planner continue
return planner
elif last_speaker is researcher:
# Pass it to the designer to make relevant graphics if needed
return designer
# Issue probably arises here
else:
# Default to auto speaker selection method
return "auto"
Step 4: Create groupchat:
groupchat = autogen.GroupChat(
agents=[user_proxy, planner, researcher, desinger],
messages=[],
max_round=20,
speaker_selection_method=custom_speaker_selection_func,
)
manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)
Step 5: Initiate
# Assumes task
chat_history = user_proxy.initiate_chat(
manager,
message=task,
)
Model Used
gpt-4
Expected Behavior
End execution or ask user to end
Screenshots and logs
No response
Additional Information
Python 3.11.4
@RRaffay do you have examples of how you initialized those agents? e.g. exact params, etc.. to be able to reproduce it
# Create researcher agent
researcher = GPTAssistantAgent(
name="researcher",
description="Researcher. Given a task, please determine what information is needed to complete the task.",
llm_config={
"config_list": config_list,
"assistant_id": "asst_pC5ktEnZlFctJfstuGMiSUMn"
}
)
researcher.register_function(
function_map={
"summarizer": summarizer,
"google_search": google_search
}
)
# Other agents
user_proxy = autogen.UserProxyAgent(
name="Admin",
system_message="A human admin. Give the task, and send instructions to manager to refine the consulting readout in the form of a MARP markdown presentation.",
code_execution_config=False,
)
planner = autogen.AssistantAgent(
name="Planner",
system_message="""Planner. Given a task, please determine what information is needed to complete the task.
Please note that the information will all be retrieved using Python code. Please only suggest information that can be retrieved using Python code.
""",
llm_config=llm_config,
)
engineer = autogen.AssistantAgent(
name="Data_Engineer",
llm_config=llm_config,
system_message="""Data_Engineer. You write python/bash to retrieve and visualize relevant data. Wrap the code in a code block that specifies the script type. The user can't modify your code. So do not suggest incomplete code which requires others to modify. Don't use a code block if it's not intended to be executed by the executor.
Don't include multiple code blocks in one response. Do not ask others to copy and paste the result. Check the execution result returned by the executor.
If the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.
""",
)
manager = autogen.AssistantAgent(
name="Manager",
llm_config=llm_config,
system_message="""Manager. Please write content for a presentation given the entity of interest, domain of interest, table of contents and scope of work. Note that your job is to come up with the key points to be researched that can be looked into by a researcher. Don't write any code.""",
)
designer = autogen.AssistantAgent(
name="Design_Expert",
llm_config=llm_config,
system_message="""Design Expert. You are an expert at taking in research reports and creating beautiful marp (markdown presentation ecosystem) presentations from them. Put the content in pseudo ```md``` code block. You will do this for a task based on previous chat history. Note that your job is to format the research for a presentation. Don't write any code.""",
)
executor = autogen.UserProxyAgent(
name="Executor",
system_message="Executor. Execute the code written by the engineer and report the result.",
description="Executor should always be called after the engineer has written code to be executed.",
human_input_mode="NEVER",
code_execution_config={
"last_n_messages": 3,
"work_dir": "paper",
"use_docker": False,
}, # Please set use_docker=True if docker is available to run the generated code. Using docker is safer than running the generated code directly.
)
Was able to reproduce this issue. The solution was to give a description for all the AssistantAgents
@RRaffay I wasn't able to reproduce this error, try using the latest version of AutoGen
from logging import warn
import os
import autogen
from autogen.agentchat.contrib.gpt_assistant_agent import GPTAssistantAgent
def bug(gc: autogen.GroupChat):
roles = []
for agent in gc.agents:
print(f"Agent '{agent.name}': {agent.description}")
if agent.description.strip() == "":
warn(f"The agent '{agent.name}' has an empty description, and may not work well with GroupChat.")
roles.append(f"{agent.name}: {agent.description}".strip())
config_list = [{"model": "gpt-3.5-turbo", "api_key": os.environ.get("OPENAI_API_KEY")}]
researcher = GPTAssistantAgent(
name="researcher",
description="Researcher. Given a task, please determine what information is needed to complete the task.",
llm_config={"config_list": config_list},
)
llm_config = {"config_list": config_list}
# Other agents
user_proxy = autogen.UserProxyAgent(
name="Admin",
system_message="A human admin. Give the task, and send instructions to manager to refine the consulting readout in the form of a MARP markdown presentation.",
code_execution_config=False,
)
planner = autogen.AssistantAgent(
name="Planner",
system_message="""Planner. Given a task, please determine what information is needed to complete the task.
Please note that the information will all be retrieved using Python code. Please only suggest information that can be retrieved using Python code.
""",
llm_config=llm_config,
)
engineer = autogen.AssistantAgent(
name="Data_Engineer",
llm_config=llm_config,
system_message="""Data_Engineer. You write python/bash to retrieve and visualize relevant data. Wrap the code in a code block that specifies the script type. The user can't modify your code. So do not suggest incomplete code which requires others to modify. Don't use a code block if it's not intended to be executed by the executor.
Don't include multiple code blocks in one response. Do not ask others to copy and paste the result. Check the execution result returned by the executor.
If the result indicates there is an error, fix the error and output the code again. Suggest the full code instead of partial code or code changes. If the error can't be fixed or if the task is not solved even after the code is executed successfully, analyze the problem, revisit your assumption, collect additional info you need, and think of a different approach to try.
""",
)
manager = autogen.AssistantAgent(
name="Manager",
llm_config=llm_config,
system_message="""Manager. Please write content for a presentation given the entity of interest, domain of interest, table of contents and scope of work. Note that your job is to come up with the key points to be researched that can be looked into by a researcher. Don't write any code.""",
)
designer = autogen.AssistantAgent(
name="Design_Expert",
llm_config=llm_config,
system_message="""Design Expert. You are an expert at taking in research reports and creating beautiful marp (markdown presentation ecosystem) presentations from them. Put the content in pseudo ```md``` code block. You will do this for a task based on previous chat history. Note that your job is to format the research for a presentation. Don't write any code.""",
)
executor = autogen.UserProxyAgent(
name="Executor",
system_message="Executor. Execute the code written by the engineer and report the result.",
description="Executor should always be called after the engineer has written code to be executed.",
human_input_mode="NEVER",
code_execution_config={
"last_n_messages": 3,
"work_dir": "paper",
"use_docker": False,
}, # Please set use_docker=True if docker is available to run the generated code. Using docker is safer than running the generated code directly.
)
def custom_speaker_selection_func(last_speaker: autogen.Agent, groupchat: autogen.GroupChat):
"""Define a customized speaker selection function."""
messages = groupchat.messages
if len(messages) <= 1:
return planner
elif last_speaker is planner:
if messages[-1]["content"].strip() != "":
# Pass it to the researcher to carry out the research for the content
return researcher
else:
# If the planner's message is empty, let the planner continue
return planner
elif last_speaker is researcher:
# Pass it to the designer to make relevant graphics if needed
return designer
# Issue probably arises here
else:
# Default to auto speaker selection method
return "auto"
groupchat = autogen.GroupChat(
agents=[user_proxy, planner, researcher, designer],
messages=[],
max_round=20,
speaker_selection_method=custom_speaker_selection_func,
)
manager = autogen.GroupChatManager(groupchat=groupchat, llm_config=llm_config)
task = "write a python code to find the number of rows and columns in a table"
# Assumes task
chat_history = user_proxy.initiate_chat(manager, message=task)
bug(groupchat)
I ran this on the latest branch as well and it works for me, can we close this issue.
Hi guys,
facing same issue, how was that fixed?