Skip to content

A programming framework for agentic AI

cover function calls with no arguments (#1185)

Yiran Wu07b97eb469ef
diff --git a/flaml/autogen/agentchat/responsive_agent.py b/flaml/autogen/agentchat/responsive_agent.py
index c6af2172a..1daa35ec9 100644
--- a/flaml/autogen/agentchat/responsive_agent.py
+++ b/flaml/autogen/agentchat/responsive_agent.py
@@ -953,7 +953,7 @@ class ResponsiveAgent(Agent):
content = f"Error: {e}\n You argument should follow json format."
# Try to execute the function
- if arguments:
+ if arguments is not None:
print(
colored(f"\n>>>>>>>> EXECUTING FUNCTION {func_name}...", "magenta"),
flush=True,
diff --git a/test/autogen/test_function_call.py b/test/autogen/test_function_call.py
index f566bfbf8..2288a5d0a 100644
--- a/test/autogen/test_function_call.py
+++ b/test/autogen/test_function_call.py
@@ -118,6 +118,14 @@ def test_execute_function():
assert user.execute_function(func_call=func_call)[1]["content"] == "15"
assert user.execute_function(func_call=func_call)[1]["content"] == "20"
+ # 3. test calling a function with no arguments
+ def get_number():
+ return 42
+
+ user = UserProxyAgent("user", function_map={"get_number": get_number})
+ func_call = {"name": "get_number", "arguments": "{}"}
+ assert user.execute_function(func_call)[1]["content"] == "42"
+
if __name__ == "__main__":
test_json_extraction()