langchain load_tools() throws KeyError for requests

langchain load_tools() throws KeyError for ‘requests’

Yesterday I was wiring up a quick agent and called:

from langchain.agents import load_tools
tools = load_tools(["requests"])

The import blew up with:

File ".../langchain/agents/load_tools.py", line 78, in load_tools
    tool = TOOL_NAME_TO_CLASS[name]
KeyError: 'requests'

Python 3.11, langchain 0.0.259, running on Windows 11 PowerShell.

requests was installed. The issue was that this version of langchain did not ship the RequestsTool map.

Fix:

  • run pip install --upgrade langchain (pulled 0.1.14)
  • run the script again with the same call

Everything worked.

Older langchain builds drop the mapping for some tools even when the package is present. Upgrade first; if the tool name still fails try requests_all in the list.

comments powered by Disqus