How LangChain defines tools
A LangChain tool has three required elements: a name that identifies it to the model, a description that explains what it does and when to use it (written for the model to read, not the developer), and an input schema that defines what arguments it accepts. The model uses the name and description to decide whether to call the tool and the schema to format the call correctly. The tool's implementation is a Python function that receives the parsed arguments and returns a result — which can be a string, a structured object, or an error message. LangChain provides both a decorator-based API for converting existing Python functions to tools and a class-based API for tools that require more configuration.
Pre-built tools and toolkits
LangChain includes a library of pre-built tool integrations for common use cases: web search via various search APIs, website content retrieval, SQL database querying, Python code execution, file system access, Wikipedia lookup, and many others. Toolkits group related tools together — a SQL toolkit includes tools for introspecting the database schema and executing queries; a Python toolkit includes tools for writing and executing code in a sandboxed environment. These pre-built tools accelerate development for common integrations but often need customization for production use — the default implementations may not match the security requirements, error handling, or data format of the specific application.
Tool errors and fallback handling
Tools that fail — due to API errors, invalid inputs, or execution exceptions — return error messages to the model rather than crashing the agent. The model can interpret these errors and decide how to proceed: retrying with different arguments, using an alternative tool, or informing the user that the operation failed. The quality of error messages affects the model's ability to recover: an error message that explains what went wrong and what valid inputs look like enables smarter recovery than a generic exception traceback. Designing tool error handling with the model's interpretation in mind — writing error messages that are informative to a language model — is a practice that significantly affects agent reliability in the face of inevitable tool failures.