Skip to content

Commit

Permalink
core[patch]: Fix FunctionCallbackHandler._on_tool_end (#22908)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kiarina committed Jun 14, 2024
1 parent b61de97 commit 8171efd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion libs/core/langchain_core/tracers/stdout.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def _on_tool_end(self, run: Run) -> None:
+ 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:
Expand Down

0 comments on commit 8171efd

Please sign in to comment.