diff --git a/autogpts/autogpt/autogpt/agents/features/watchdog.py b/autogpts/autogpt/autogpt/agents/features/watchdog.py index 9beb69e7..8113def2 100644 --- a/autogpts/autogpt/autogpt/agents/features/watchdog.py +++ b/autogpts/autogpt/autogpt/agents/features/watchdog.py @@ -37,20 +37,28 @@ class WatchdogMixin: WatchdogMixin, self ).propose_action(*args, **kwargs) - if ( - not self.config.big_brain - and len(self.event_history) > 1 - and self.config.fast_llm != self.config.smart_llm - ): - # Detect repetitive commands - previous_cycle = self.event_history.episodes[self.event_history.cursor - 1] - if ( - command_name == previous_cycle.action.name - and command_args == previous_cycle.action.args + if not self.config.big_brain and self.config.fast_llm != self.config.smart_llm: + previous_command, previous_command_args = None, None + if len(self.event_history) > 1: + # Detect repetitive commands + previous_cycle = self.event_history.episodes[ + self.event_history.cursor - 1 + ] + previous_command = previous_cycle.action.name + previous_command_args = previous_cycle.action.args + + rethink_reason = "" + + if not command_name: + rethink_reason = "AI did not specify a command" + elif ( + command_name == previous_command + and command_args == previous_command_args ): - logger.info( - f"Repetitive command detected ({command_name}), re-thinking with SMART_LLM..." - ) + rethink_reason = f"Repititive command detected ({command_name})" + + if rethink_reason: + logger.info(f"{rethink_reason}, re-thinking with SMART_LLM...") with ExitStack() as stack: @stack.callback