Deepagent import error
ImportError: cannot import name 'ToolCallRequest' from 'langchain.agents.middleware.types'
Python:3.12.6
what version of langchain are you on?
I Encountered the Same Issue
I'm facing the exact same problem as described. ImportError: cannot import name 'ToolCallRequest' from 'langchain.agents.middleware.types' Please refer to the attached image for details.
My Package Versions
Below are the versions of the relevant packages in my environment for reference.
Acknowledgement
Thank you very much for your time and assistance in looking into this issue.
That’s because langchain_anthropic incorrectly imports ToolCallRequest. The correct import path should be:
from langchain.tools.tool_node import ToolCallRequest
However, langchain version 1.0.3 happens to import that class under langchain.agents.middleware.types. So as a temporary fix, you can simply upgrade langchain to 1.0.3.
Quick and effective solution—thanks!
Updating the LangChain version to 1.0.3 resolved the DeepAgent-related issue, but introduced other problems.
ImportError: cannot import name 'InputTokenDetails' from 'langchain_core.messages'
Please refer to the attached image for details.
How can I fix this issue? Thank you.
update langchain-core to 1.0.3
Problem solved, thanks!