From b381084a3aec904f08fd13f384a055087a804e08 Mon Sep 17 00:00:00 2001 From: David Gardner Date: Thu, 1 Feb 2024 08:20:29 -0800 Subject: [PATCH] Catch and log exceptions occurring while executing a langchain agent node --- morpheus/llm/nodes/langchain_agent_node.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/morpheus/llm/nodes/langchain_agent_node.py b/morpheus/llm/nodes/langchain_agent_node.py index 3fbb018df0..5a18e72f01 100644 --- a/morpheus/llm/nodes/langchain_agent_node.py +++ b/morpheus/llm/nodes/langchain_agent_node.py @@ -66,7 +66,10 @@ async def _run_single(self, **kwargs: dict[str, typing.Any]) -> dict[str, typing return results # We are not dealing with a list, so run single - return await self._agent_executor.arun(**kwargs) + try: + return await self._agent_executor.arun(**kwargs) + except Exception as e: + logger.exception("Error running agent: %s: %s", kwargs, e) async def execute(self, context: LLMContext) -> LLMContext: