Skip to content

The agent engineering platform.

Handle null action in AutoGPT Agent (#3274)

Zander Chasea71a2c0eb295
diff --git a/langchain/experimental/autonomous_agents/autogpt/output_parser.py b/langchain/experimental/autonomous_agents/autogpt/output_parser.py
index d2b98c395b..3ce36afe04 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}"}
)