crewAI icon indicating copy to clipboard operation
crewAI copied to clipboard

Tool callbacks

Open BespalovSergey opened this issue 1 year ago • 9 comments

Hello, we use callback processing to monitor the operation of tools, tell why you use the private _run method when calling tools, as a result, tool callbacks are not called. It is quite important to monitor and process the operation of tools with callbacks.

BespalovSergey avatar Jun 10 '24 09:06 BespalovSergey

Private functions / methods in Python are not enforced, meaning you can still call them, call back functions do work in crewAI, feel free to drop you crewAI code here's

theCyberTech avatar Jun 10 '24 09:06 theCyberTech

BaseTool class in Langchain has a public run method, which is the way a tool should be called. Besides calling self._run, it also takes care of things such as error handling, and more importantly, fires callbacks on tool start and end.

We use callbacks for monitoring and debugging agents, but currently tool calls are not logged because of callbacks not being called. What do you think about either using BaseTool's public methods or firing the events inside CrewAi code if the former is not possible for some reason?

whimo avatar Jun 11 '24 08:06 whimo

I understand but I don't think there is a functional difference when defining run or _run, correct me if I'm wrong

theCyberTech avatar Jun 11 '24 08:06 theCyberTech

Not sure what you mean by that. The difference is in the auxiliary stuff that happens inside run before and after it executes _run, and it's quite important for our use cases.

You can refer to the Langchain code: https://github.com/langchain-ai/langchain/blob/27b9ea14a51398e8ff2a4972026178778f85134b/libs/core/langchain_core/tools.py#L355

This code calls on_tool_start, on_tool_error, on_tool_end callbacks regardless of the logic of the _run method.

whimo avatar Jun 11 '24 09:06 whimo

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Aug 17 '24 12:08 github-actions[bot]

Bumping this because the issue is still present.

whimo avatar Aug 17 '24 12:08 whimo

Thanks. Eagerly waiting for a fix for this. We need to show tool output to custom UI using on_tool_start, on_tool_error, on_tool_end callbacks

raviraval79 avatar Aug 24 '24 12:08 raviraval79

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Sep 24 '24 12:09 github-actions[bot]

Bumping this because the issue is still present.

whimo avatar Sep 25 '24 11:09 whimo

This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Oct 26 '24 12:10 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Oct 31 '24 12:10 github-actions[bot]