InvalidTool Class — langchain Architecture
Architecture documentation for the InvalidTool class in tools.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD 1fa17fb9_bf5e_55fe_17f6_d2a92f558f45["InvalidTool"] 18e85ff8_9a5d_f800_f722_027398dc89e7["BaseTool"] 1fa17fb9_bf5e_55fe_17f6_d2a92f558f45 -->|extends| 18e85ff8_9a5d_f800_f722_027398dc89e7 20a07e07_26ee_ded7_a31f_ef7d03a44e8b["tools.py"] 1fa17fb9_bf5e_55fe_17f6_d2a92f558f45 -->|defined in| 20a07e07_26ee_ded7_a31f_ef7d03a44e8b 69c40ce1_1787_7518_4174_ac0e82581644["_run()"] 1fa17fb9_bf5e_55fe_17f6_d2a92f558f45 -->|method| 69c40ce1_1787_7518_4174_ac0e82581644 2548f89c_fb13_5aef_01f6_2dc696a6bcc2["_arun()"] 1fa17fb9_bf5e_55fe_17f6_d2a92f558f45 -->|method| 2548f89c_fb13_5aef_01f6_2dc696a6bcc2
Relationship Graph
Source Code
libs/langchain/langchain_classic/agents/tools.py lines 11–45
class InvalidTool(BaseTool):
"""Tool that is run when invalid tool name is encountered by agent."""
name: str = "invalid_tool"
"""Name of the tool."""
description: str = "Called when tool name is invalid. Suggests valid tool names."
"""Description of the tool."""
@override
def _run(
self,
requested_tool_name: str,
available_tool_names: list[str],
run_manager: CallbackManagerForToolRun | None = None,
) -> str:
"""Use the tool."""
available_tool_names_str = ", ".join(list(available_tool_names))
return (
f"{requested_tool_name} is not a valid tool, "
f"try one of [{available_tool_names_str}]."
)
@override
async def _arun(
self,
requested_tool_name: str,
available_tool_names: list[str],
run_manager: AsyncCallbackManagerForToolRun | None = None,
) -> str:
"""Use the tool asynchronously."""
available_tool_names_str = ", ".join(list(available_tool_names))
return (
f"{requested_tool_name} is not a valid tool, "
f"try one of [{available_tool_names_str}]."
)
Extends
Source
Frequently Asked Questions
What is the InvalidTool class?
InvalidTool is a class in the langchain codebase, defined in libs/langchain/langchain_classic/agents/tools.py.
Where is InvalidTool defined?
InvalidTool is defined in libs/langchain/langchain_classic/agents/tools.py at line 11.
What does InvalidTool extend?
InvalidTool extends BaseTool.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free