A structured tool is LangChain’s abstraction, introduced in May 2023, for an action an agent can take
that accepts an arbitrary number of inputs of arbitrary types rather than a single input string. It wraps
a function so that an agent can call it, and is defined by four parts: a name that tells the agent
which tool to pick, a description explaining when and why to use it, an args_schema — a Pydantic
model declaring the arguments and their types — and _run and _arun functions holding the tool’s
synchronous and asynchronous logic.
Usage
The term belongs to LangChain, where the StructuredTool class was announced in
Structured Tools. The args_schema does two jobs on LangChain’s account: it tells the
agent what information the tool needs, and it validates the agent’s inputs before the tool runs. A tool
can be built from a plain function with StructuredTool.from_function(), which infers the schema from
the function’s signature, or by subclassing BaseTool for more control. It did not replace the earlier string tool: the original Tool class shares a base class with StructuredTool,
and a tool that takes one string argument is still treated as a string tool. LangChain released a
StructuredChatAgent to use such tools, because the prompts and output parsers of its earlier agents
did not work with multi-argument tools without customization.