diff --git a/libs/langchain/langchain/agents/output_parsers/json.py b/libs/langchain/langchain/agents/output_parsers/json.py index 2dbc56178ff..e89a9bfa6ef 100644 --- a/libs/langchain/langchain/agents/output_parsers/json.py +++ b/libs/langchain/langchain/agents/output_parsers/json.py @@ -50,9 +50,10 @@ class JSONAgentOutputParser(AgentOutputParser): if response["action"] == "Final Answer": return AgentFinish({"output": response["action_input"]}, text) else: - return AgentAction( - response["action"], response.get("action_input", {}), text - ) + action_input = response.get("action_input", {}) + if action_input is None: + action_input = {} + return AgentAction(response["action"], action_input, text) except Exception as e: raise OutputParserException(f"Could not parse LLM output: {text}") from e