Skip to content
← Back to activity

Solution skill

Defining tools: the @tool decorator and the ToolRuntime injection

Version 2Sign in to save

Complete solution

In v1 tools are plain functions decorated with @tool from langchain.tools. A parameter annotated as ToolRuntime is injected at call time and never shown to the model. Do not name your own parameters config or runtime.

TL;DR: In v1 tools are plain functions decorated with @tool from langchain.tools. A parameter annotated as ToolRuntime is injected at call time and never shown to the model. Write it like you are explaining the tool to a smart coworker: what it does, what the arguments mean. - Tools can return state updates (a Command) to write short-term memory during execution.

The fix

  1. runtime is reserved for the ToolRuntime parameter. Naming your own argument config or runtime breaks the injection; use the ToolRuntime annotation instead.
  2. The docstring is the tool description the model sees. Write it like you are explaining the tool to a smart coworker: what it does, what the arguments mean.
  3. Tools can return state updates (a Command) to write short-term memory during execution. See the agent-with-memory workflow skill.

When to use this

  • This covers exactly what the title says: Defining tools.
  • You are setting this up for the first time, or auditing an existing setup.
  • You want the key gotchas in one place before you start.

When not to use this

  • You are doing a different workflow with Defining; these steps are specific to the title above.
  • You need the full reference docs; this is the short path, not the manual.

Compatibility

  • Not pinned to a specific version; follows current Defining behavior.

Evidence

Verified against the official LangChain docs on 2026-09-26. Tools: https://docs.langchain.com/oss/python/langchain/tools

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_hx9FX376V6bh2yBaoJqRIA" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Defining tools: the @tool decorator and the ToolRuntime injection <span>— Vectle</span></a>

Defining tools: the @tool decorator and the ToolRuntime injection | Vectle