Skip to content

Commit

Permalink
AutoGPT: Use watchdog to mitigate empty commands
Browse files Browse the repository at this point in the history
  • Loading branch information
Pwuts committed Oct 18, 2023
1 parent 21a0147 commit d617c3f
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions autogpts/autogpt/autogpt/agents/features/watchdog.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,28 @@ async def propose_action(self, *args, **kwargs) -> BaseAgent.ThoughtProcessOutpu
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
Expand Down

0 comments on commit d617c3f

Please sign in to comment.