AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
fix: Prevent AutoGPT crashes when LLM does not use a command
Reinier van der Leer0bd776dde561
diff --git a/autogpts/autogpt/autogpt/agents/agent.py b/autogpts/autogpt/autogpt/agents/agent.pyindex 633c3e62b9..13275a4e85 100644--- a/autogpts/autogpt/autogpt/agents/agent.py+++ b/autogpts/autogpt/autogpt/agents/agent.py@@ -187,13 +187,14 @@ class Agent(NEXT_ACTION_FILE_NAME,)- self.event_history.register_action(- Action(- name=command_name,- args=arguments,- reasoning=assistant_reply_dict["thoughts"]["reasoning"],+ if command_name:+ self.event_history.register_action(+ Action(+ name=command_name,+ args=arguments,+ reasoning=assistant_reply_dict["thoughts"]["reasoning"],+ ))- )return command_name, arguments, assistant_reply_dictdiff --git a/autogpts/autogpt/autogpt/app/agent_protocol_server.py b/autogpts/autogpt/autogpt/app/agent_protocol_server.pyindex 84573edc40..1426178f37 100644--- a/autogpts/autogpt/autogpt/app/agent_protocol_server.py+++ b/autogpts/autogpt/autogpt/app/agent_protocol_server.py@@ -226,6 +226,8 @@ class AgentProtocolServer:if execute_command == ask_user.__name__: # HACKexecute_result = ActionSuccessResult(outputs=user_input)agent.event_history.register_result(execute_result)+ elif not execute_command:+ execute_result = Noneelif execute_approved:step = await self.db.update_step(task_id=task_id,diff --git a/autogpts/autogpt/autogpt/app/main.py b/autogpts/autogpt/autogpt/app/main.pyindex c974ae15ae..ff454e4d0a 100644--- a/autogpts/autogpt/autogpt/app/main.py+++ b/autogpts/autogpt/autogpt/app/main.py@@ -556,14 +556,17 @@ async def run_interaction_loop(handle_stop_signal()- result = await agent.execute(command_name, command_args, user_input)+ if command_name:+ result = await agent.execute(command_name, command_args, user_input)- if result.status == "success":- logger.info(result, extra={"title": "SYSTEM:", "title_color": Fore.YELLOW})- elif result.status == "error":- logger.warn(- f"Command {command_name} returned an error: {result.error or result.reason}"- )+ if result.status == "success":+ logger.info(+ result, extra={"title": "SYSTEM:", "title_color": Fore.YELLOW}+ )+ elif result.status == "error":+ logger.warn(+ f"Command {command_name} returned an error: {result.error or result.reason}"+ )def update_user(