From ff063981e25682feeca03d7cf9654449e0f4583f Mon Sep 17 00:00:00 2001 From: Hunter Lovell Date: Fri, 7 Nov 2025 14:34:51 -0800 Subject: [PATCH] chore(oss/js): fix `ToolRuntime` references in docs --- src/oss/langchain/context-engineering.mdx | 25 ++++++++--------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/oss/langchain/context-engineering.mdx b/src/oss/langchain/context-engineering.mdx index 0c4ad3d7ab..dc050eb6e7 100644 --- a/src/oss/langchain/context-engineering.mdx +++ b/src/oss/langchain/context-engineering.mdx @@ -691,7 +691,7 @@ import { tool } from "@langchain/core/tools"; import { z } from "zod"; const searchOrders = tool( - async ({ userId, status, limit = 10 }) => { + async ({ userId, status, limit }) => { // Implementation here }, { @@ -1612,11 +1612,10 @@ Most real-world tools need more than just the LLM's parameters. They need user I ```typescript import * as z from "zod"; - import { tool } from "@langchain/core/tools"; - import { createAgent } from "langchain"; + import { createAgent, tool, type ToolRuntime } from "langchain"; const checkAuthentication = tool( - async (_, { runtime }) => { + async (_, runtime: ToolRuntime) => { // Read from State: check current auth status const currentState = runtime.state; const isAuthenticated = currentState.authenticated || false; @@ -1683,15 +1682,14 @@ Most real-world tools need more than just the LLM's parameters. They need user I ```typescript import * as z from "zod"; - import { tool } from "@langchain/core/tools"; - import { createAgent } from "langchain"; + import { createAgent, tool, type ToolRuntime } from "langchain"; const contextSchema = z.object({ userId: z.string(), }); const getPreference = tool( - async ({ preferenceKey }, { runtime }) => { + async ({ preferenceKey }, runtime: ToolRuntime) => { const userId = runtime.context.userId; // Read from Store: get existing preferences @@ -1781,7 +1779,7 @@ Most real-world tools need more than just the LLM's parameters. They need user I }); const fetchUserData = tool( - async ({ query }, { runtime }) => { + async ({ query }, runtime: ToolRuntime) => { // Read from Runtime Context: get API key and DB connection const { userId, apiKey, dbConnection } = runtime.context; @@ -1856,7 +1854,7 @@ and update the memory of the agent to make important context available to future import { Command } from "@langchain/langgraph"; const authenticateUser = tool( - async ({ password }, { runtime }) => { + async ({ password }) => { // Perform authentication if (password === "correct") { // Write to State: mark as authenticated using Command @@ -1929,15 +1927,10 @@ and update the memory of the agent to make important context available to future ```typescript import * as z from "zod"; - import { tool } from "@langchain/core/tools"; - import { createAgent } from "langchain"; - - const contextSchema = z.object({ - userId: z.string(), - }); + import { createAgent, tool, type ToolRuntime } from "langchain"; const savePreference = tool( - async ({ preferenceKey, preferenceValue }, { runtime }) => { + async ({ preferenceKey, preferenceValue }, runtime: ToolRuntime) => { const userId = runtime.context.userId; // Read existing preferences