Skip to content

A programming framework for agentic AI

Minor fix groupchat (#904)

Yiran Wu8a26d3b3cd39
diff --git a/autogen/agentchat/groupchat.py b/autogen/agentchat/groupchat.py
index 03251eccf..1e6a636c8 100644
--- a/autogen/agentchat/groupchat.py
+++ b/autogen/agentchat/groupchat.py
@@ -170,7 +170,7 @@ Then select the next role from {[agent.name for agent in agents]} to play. Only
return agents[0], agents
elif not agents:
raise ValueError(
- f"No agent can execute the function {self.messages[-1]['name']}. "
+ f"No agent can execute the function {self.messages[-1]['function_call']['name']}. "
"Please check the function_map of the agents."
)
# remove the last speaker from the list to avoid selecting the same speaker if allow_repeat_speaker is False
diff --git a/test/agentchat/test_function_call_groupchat.py b/test/agentchat/test_function_call_groupchat.py
index 02fe14a3e..7b5266195 100644
--- a/test/agentchat/test_function_call_groupchat.py
+++ b/test/agentchat/test_function_call_groupchat.py
@@ -71,5 +71,33 @@ def test_function_call_groupchat():
user_proxy.initiate_chat(manager, message="Let's start the game!")
+def test_no_function_map():
+ dummy1 = autogen.UserProxyAgent(
+ name="User_proxy",
+ system_message="A human admin that will execute function_calls.",
+ human_input_mode="NEVER",
+ )
+
+ dummy2 = autogen.UserProxyAgent(
+ name="User_proxy",
+ system_message="A human admin that will execute function_calls.",
+ human_input_mode="NEVER",
+ )
+ groupchat = autogen.GroupChat(agents=[dummy1, dummy2], messages=[], max_round=7)
+ groupchat.messages = [
+ {
+ "role": "assistant",
+ "content": None,
+ "function_call": {"name": "get_random_number", "arguments": "{}"},
+ }
+ ]
+ with pytest.raises(
+ ValueError,
+ match="No agent can execute the function get_random_number. Please check the function_map of the agents.",
+ ):
+ groupchat._prepare_and_select_agents(dummy2)
+
+
if __name__ == "__main__":
test_function_call_groupchat()
+ test_no_function_map()