Skip to content

A programming framework for agentic AI

fix execute a_generate_reply with function_call: None (#3250)

Juan Arteroc1289b4da775
diff --git a/autogen/agentchat/conversable_agent.py b/autogen/agentchat/conversable_agent.py
index eabe6d6d4..e19cbd56d 100644
--- a/autogen/agentchat/conversable_agent.py
+++ b/autogen/agentchat/conversable_agent.py
@@ -1658,8 +1658,8 @@ class ConversableAgent(LLMAgent):
if messages is None:
messages = self._oai_messages[sender]
message = messages[-1]
- if "function_call" in message:
- func_call = message["function_call"]
+ func_call = message.get("function_call")
+ if func_call:
func_name = func_call.get("name", "")
func = self._function_map.get(func_name, None)
if func and inspect.iscoroutinefunction(func):
diff --git a/test/agentchat/test_function_and_tool_calling.py b/test/agentchat/test_function_and_tool_calling.py
index 4e0775d01..97727fe5c 100644
--- a/test/agentchat/test_function_and_tool_calling.py
+++ b/test/agentchat/test_function_and_tool_calling.py
@@ -33,6 +33,7 @@ async def _a_tool_func_error(arg1: str, arg2: str) -> str:
_tool_use_message_1 = {
"role": "assistant",
"content": None,
+ "function_call": None,
"tool_calls": [
{
"id": "1",
@@ -56,6 +57,7 @@ _tool_use_message_1 = {
_tool_use_message_1_bad_json = {
"role": "assistant",
"content": None,
+ "function_call": None,
"tool_calls": [
{
"id": "1",