From bdf865d8e8dce4ac7a73df649fa8bb2fbd26bdee Mon Sep 17 00:00:00 2001 From: Harrison Chase Date: Tue, 3 Oct 2023 09:00:17 -0700 Subject: [PATCH] better error message on parsing errors (#11342) --- libs/langchain/langchain/agents/agent.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libs/langchain/langchain/agents/agent.py b/libs/langchain/langchain/agents/agent.py index f46e1595c3..47aa3ae972 100644 --- a/libs/langchain/langchain/agents/agent.py +++ b/libs/langchain/langchain/agents/agent.py @@ -931,7 +931,12 @@ class AgentExecutor(Chain): else: raise_error = False if raise_error: - raise e + raise ValueError( + "An output parsing error occurred. " + "In order to pass this error back to the agent and have it try " + "again, pass `handle_parsing_errors=True` to the AgentExecutor. " + f"This is the error: {str(e)}" + ) text = str(e) if isinstance(self.handle_parsing_errors, bool): if e.send_to_llm: @@ -1027,7 +1032,12 @@ class AgentExecutor(Chain): else: raise_error = False if raise_error: - raise e + raise ValueError( + "An output parsing error occurred. " + "In order to pass this error back to the agent and have it try " + "again, pass `handle_parsing_errors=True` to the AgentExecutor. " + f"This is the error: {str(e)}" + ) text = str(e) if isinstance(self.handle_parsing_errors, bool): if e.send_to_llm: