A programming framework for agentic AI
Improve error messaging (#3236)
Umer Mansoor36ead68c9ac6
diff --git a/autogen/agentchat/conversable_agent.py b/autogen/agentchat/conversable_agent.pyindex 674c8b924..2d8958f32 100644--- a/autogen/agentchat/conversable_agent.py+++ b/autogen/agentchat/conversable_agent.py@@ -2234,7 +2234,7 @@ class ConversableAgent(LLMAgent):arguments = json.loads(input_string)except json.JSONDecodeError as e:arguments = None- content = f"Error: {e}\n You argument should follow json format."+ content = f"Error: {e}\n The argument must be in JSON format."# Try to execute the functionif arguments is not None:@@ -2291,7 +2291,7 @@ class ConversableAgent(LLMAgent):arguments = json.loads(input_string)except json.JSONDecodeError as e:arguments = None- content = f"Error: {e}\n You argument should follow json format."+ content = f"Error: {e}\n The argument must be in JSON format."# Try to execute the functionif arguments is not None:diff --git a/test/agentchat/test_function_and_tool_calling.py b/test/agentchat/test_function_and_tool_calling.pyindex 893fbe351..4e0775d01 100644--- a/test/agentchat/test_function_and_tool_calling.py+++ b/test/agentchat/test_function_and_tool_calling.py@@ -94,11 +94,11 @@ _tool_use_message_1_bad_json_expected_reply = {{"tool_call_id": "1","role": "tool",- "content": "Error: Expecting property name enclosed in double quotes: line 1 column 37 (char 36)\n You argument should follow json format.",+ "content": "Error: Expecting property name enclosed in double quotes: line 1 column 37 (char 36)\n The argument must be in JSON format.",},{"tool_call_id": "2", "role": "tool", "content": "_tool_func_2: value3 value4"},],- "content": "Error: Expecting property name enclosed in double quotes: line 1 column 37 (char 36)\n You argument should follow json format.\n\n_tool_func_2: value3 value4",+ "content": "Error: Expecting property name enclosed in double quotes: line 1 column 37 (char 36)\n The argument must be in JSON format.\n\n_tool_func_2: value3 value4",}_tool_use_message_1_error_expected_reply = {@@ -154,7 +154,7 @@ _function_use_message_1_expected_reply = {_function_use_message_1_bad_json_expected_reply = {"name": "_tool_func_1","role": "function",- "content": "Error: Expecting property name enclosed in double quotes: line 1 column 37 (char 36)\n You argument should follow json format.",+ "content": "Error: Expecting property name enclosed in double quotes: line 1 column 37 (char 36)\n The argument must be in JSON format.",}_function_use_message_1_error_expected_reply = {diff --git a/test/agentchat/test_function_call.py b/test/agentchat/test_function_call.pyindex 0f1d4f909..7023a709d 100755--- a/test/agentchat/test_function_call.py+++ b/test/agentchat/test_function_call.py@@ -115,7 +115,7 @@ def test_execute_function():"name": "add_num","arguments": '{ "num_to_be_added": 5, given_num: 10 }',} # should be "given_num" with quotes- assert "You argument should follow json format." in user.execute_function(func_call=wrong_json_format)[1]["content"]+ assert "The argument must be in JSON format." in user.execute_function(func_call=wrong_json_format)[1]["content"]# function execution error with wrong arguments passedwrong_args = {"name": "add_num", "arguments": '{ "num_to_be_added": 5, "given_num": 10 }'}@@ -174,7 +174,7 @@ async def test_a_execute_function():"arguments": '{ "num_to_be_added": 5, given_num: 10 }',} # should be "given_num" with quotesassert (- "You argument should follow json format."+ "The argument must be in JSON format."in (await user.a_execute_function(func_call=wrong_json_format))[1]["content"])