Agent tool execution
Run one or more model-selected tools in a LangGraph workflow.
AI Agents · Function
LangGraph's ToolNode executes tools within workflows and supports parallel calls, error handling, and state injection. It is useful when an agent needs controlled, graph-based tool execution.
A tool is a callable capability exposed to an agent. The agent can select it from the configured tool set, provide model-generated arguments, and use its result in the workflow.
new ToolNode(tools)import { createReactAgent } from "@langchain/langgraph/prebuilt";
import { tool } from "@langchain/core/tools";
import { z } from "zod";
const getWeather = tool(
async ({ city }) => `Weather for ${city}: sunny`,
{
name: "get_weather",
description: "Get the current weather for a city",
schema: z.object({ city: z.string() }),
},
);
const agent = createReactAgent({
llm,
tools: [getWeather],
});
const result = await agent.invoke({
messages: [{ role: "user", content: "What is the weather in Paris?" }],
});Defines a structured tool and supplies it to a ReAct agent, which can decide when to call it.
Run one or more model-selected tools in a LangGraph workflow.
Execute multiple independent tool calls efficiently.
Expose graph state or run context to JavaScript tools.
ToolNodeToolRuntimecreateReactAgent