From a71a2c0eb295d76a2db39c0249b6e36463e209ed Mon Sep 17 00:00:00 2001 From: Zander Chase <130414180+vowelparrot@users.noreply.github.com> Date: Thu, 20 Apr 2023 23:18:46 -0700 Subject: [PATCH] Handle null action in AutoGPT Agent (#3274) Handle the case where the command is `null` --- .../experimental/autonomous_agents/autogpt/output_parser.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/langchain/experimental/autonomous_agents/autogpt/output_parser.py b/langchain/experimental/autonomous_agents/autogpt/output_parser.py index d2b98c39..3ce36afe 100644 --- a/langchain/experimental/autonomous_agents/autogpt/output_parser.py +++ b/langchain/experimental/autonomous_agents/autogpt/output_parser.py @@ -44,7 +44,8 @@ class AutoGPTOutputParser(BaseAutoGPTOutputParser): name=parsed["command"]["name"], args=parsed["command"]["args"], ) - except KeyError: + except (KeyError, TypeError): + # If the command is null or incomplete, return an erroneous tool return AutoGPTAction( name="ERROR", args={"error": f"Incomplete command args: {parsed}"} )