---
source: https://iinventedlight.com/library/notes/langchain-custom-tools.md
title: "Define LangChain tools with @tool and type hints"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (LangChain docs); MIT (LangChain Core reference); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: LangChain docs, Tools; LangChain Core reference, tools. MIT; MIT."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-ai: LangChain @tool decorator and tool descriptions"
tags: [langchain, tools, tool-calling, agents, tool-decorator, pydantic]
client: Librarian
sources:
  - id: S1
    title: "Tools"
    publisher: LangChain docs
    url: https://docs.langchain.com/oss/python/langchain/tools
    accessed: 2026-11-19
    license: "MIT"
  - id: S2
    title: "tools"
    publisher: LangChain Core reference
    url: https://reference.langchain.com/python/langchain_core/tools/
    accessed: 2026-11-19
    license: "MIT"
---
# Define LangChain tools with @tool and type hints
**Answer:** Tools extend what agents can do. They can fetch real-time data, execute code, query external databases, and take actions. Under the hood, tools are callable functions with well-defined inputs and outputs, and those are passed to a chat model. That model decides when to invoke a tool, using the conversation context and the input arguments to provide. The simplest way to create a tool is with the `@tool` decorator.

## Define a tool

By default, the function's docstring becomes the tool's description, and that text helps the model decide when to use it. Type hints are required as they define the tool's input schema. Keep that docstring informative and concise so the model can tell when to use the tool. Prefer `snake_case` for tool names. Some model providers have issues with or reject names containing spaces or special characters. Sticking to alphanumeric characters, underscores, and hyphens helps to improve compatibility across providers.

Override the name with `@tool("web_search")` when you need something more descriptive than the function name. Override the auto-generated tool description with the `description=` argument for clearer model guidance. Define complex inputs with Pydantic models or JSON schemas, and pass them as `args_schema`.

| Name | Description |
|---|---|
| Name | The function name, or `@tool("custom_name")` |
| Description | A `description` argument |
| Input schema | Type hints, or `args_schema` with a Pydantic model or JSON schema |

## What the reference docs add

Tools are classes that an Agent uses to interact with the world, and each tool has a description. The agent uses the description to choose the right tool for the job. `create_schema_from_function` creates a Pydantic schema from a function's signature. `convert_runnable_to_tool` is also listed.

## See also

- [hf-transformers-pipeline](https://iinventedlight.com/library/notes/hf-transformers-pipeline/)
- [python-typing-annotations](https://iinventedlight.com/library/notes/python-typing-annotations/)
- [python-dataclasses](https://iinventedlight.com/library/notes/python-dataclasses/)

## Claims

- id: C1
  claim: The simplest way to create a tool is the @tool decorator.
  source: S1
  evidence: "The simplest way to create a tool is with the @tool decorator"

- id: C3
  claim: Type hints are required because they define the tool's input schema.
  source: S1
  evidence: "Type hints are required as they define the tool"

- id: C4
  claim: A tool's description is what an agent uses to choose it.
  source: S2
  evidence: "Agent uses the description to choose the right tool"

## Sources

- [S1] Tools. LangChain docs. https://docs.langchain.com/oss/python/langchain/tools . License: MIT. Accessed 2026-11-19.

- [S2] tools. LangChain Core reference. https://reference.langchain.com/python/langchain_core/tools/ . License: MIT. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: LangChain docs, Tools; LangChain Core reference, tools. MIT; MIT. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
