Skip to content

The agent engineering platform.

Relax the action input check for actions that require no input (#6357)

Xiaochao Donga15afc102c88
diff --git a/langchain/agents/chat/output_parser.py b/langchain/agents/chat/output_parser.py
index 4da19526db..c7023426aa 100644
--- a/langchain/agents/chat/output_parser.py
+++ b/langchain/agents/chat/output_parser.py
@@ -17,13 +17,15 @@ class ChatOutputParser(AgentOutputParser):
try:
action = text.split("```")[1]
response = json.loads(action.strip())
- includes_action = "action" in response and "action_input" in response
+ includes_action = "action" in response
if includes_answer and includes_action:
raise OutputParserException(
"Parsing LLM output produced a final answer "
f"and a parse-able action: {text}"
)
- return AgentAction(response["action"], response["action_input"], text)
+ return AgentAction(
+ response["action"], response.get("action_input", {}), text
+ )
except Exception:
if not includes_answer: