Open Edoch94 opened 1 month ago
Same problem here ! I think its duplicate of #24621
seems to be related to the PR https://github.com/langchain-ai/langchain/pull/24038 which adds to run_manager to the tool arg https://github.com/langchain-ai/langchain/blob/7dd6b32991e81582cb30588b84871af04ecdc76c/libs/core/langchain_core/tools.py#L603 and make it fail to serialize
going back to pip install langchain-core==0.2.12
seems to fix it for me
Hi @wulifu2hao, thanks for the help
I managed to dig a bit more using the callbacks, and I noticed exactly what you're saying
Specifically, when the AIMessageChunk
is created at the end of the first iteration done by the Agent Executor:
tool_calls
section, among the args
, I see a run_manager
key containing a CallbackManagerForToolRun
object, which is the one causing the error TypeError: Object of type CallbackManagerForToolRun is not JSON serializable
tool_calls=[{'name': 'bing_search_results_json', 'args': {'query': 'latest version of Angular', 'run_manager': <langchain_core.callbacks.manager.CallbackManagerForToolRun object at 0x7f4cce5178d0>}, 'id': 'call_ybDKJDawNevJNo2af5BILeLb', 'type': 'tool_call'}]
tool_calls
section does not include any run_manager
key, and that's why the error doesn't occurtool_calls=[{'name': 'duckduckgo_results_json', 'args': {'query': 'latest version of Angular'}, 'id': 'call_ihqRw2Ifs1wYPNcWQhUR1mgC', 'type': 'tool_call'}]
Moreover, I confirm that locking the version of langchain-core to langchain-core<=0.2.12
solves this issue and Bing Tool works
facing the same issue
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
TypeError: Object of type CallbackManagerForToolRun is not JSON serializable
Description
I'm trying use the Bing Search tool in an Agent Executor.
The search tool itself works, even the agent works, the problem is when I use it in an Agent Executor.
The same issue occurs when using the Google Search tool from the langchain-google-community package
Instead, it does not occur with DuckDuckGo
System Info
From
python -m langchain_core.sys_info