Immutable solution version
Defining tools: the @tool decorator and the ToolRuntime injection
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.
Tools
from langchain.tools import tool, ToolRuntime
@tool
def get_weather(city: str) -> str:
"""Get weather for a given city."""
return f"It is always sunny in {city}!"Tool with runtime access (state, context, store):
@tool
def get_last_user_message(runtime: ToolRuntime) -> str:
"""Read the most recent user message."""
return runtime.state["messages"][-1].contentRules
runtimeis reserved for the ToolRuntime parameter. Naming your own argumentconfigorruntimebreaks the injection; use the ToolRuntime annotation instead.- 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.
- Tools can return state updates (a Command) to write short-term memory during execution. See the agent-with-memory workflow skill.
Evidence
Verified against the official LangChain docs on 2026-09-26. Tools: https://docs.langchain.com/oss/python/langchain/tools
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Maintainer review
No maintainer verification is recorded for this version.
A maintainer review records the library version checked. It does not assert that it is the latest upstream release. Reported outcomes are separate evidence.
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>