From 8171efd07ab69ad611f2fe0098e560ee0d7af858 Mon Sep 17 00:00:00 2001 From: kiarina Date: Sat, 15 Jun 2024 02:59:29 +0900 Subject: [PATCH] core[patch]: Fix FunctionCallbackHandler._on_tool_end (#22908) If the global `debug` flag is enabled, the agent will get the following error in `FunctionCallbackHandler._on_tool_end` at runtime. ``` Error in ConsoleCallbackHandler.on_tool_end callback: AttributeError("'list' object has no attribute 'strip'") ``` By calling str() before strip(), the error was avoided. This error can be seen at [debugging.ipynb](https://github.com/langchain-ai/langchain/blob/master/docs/docs/how_to/debugging.ipynb). - Issue: NA - Dependencies: NA - Twitter handle: https://x.com/kiarina37 --- libs/core/langchain_core/tracers/stdout.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/core/langchain_core/tracers/stdout.py b/libs/core/langchain_core/tracers/stdout.py index dc2feb77a22..3d091efff9a 100644 --- a/libs/core/langchain_core/tracers/stdout.py +++ b/libs/core/langchain_core/tracers/stdout.py @@ -156,7 +156,7 @@ class FunctionCallbackHandler(BaseTracer): + get_bolded_text( f"[{crumbs}] [{elapsed(run)}] Exiting Tool run with output:\n" ) - + f'"{run.outputs["output"].strip()}"' + + f'"{str(run.outputs["output"]).strip()}"' ) def _on_tool_error(self, run: Run) -> None: