From e66df13ab0b88f17eec52aa298adf1aea145c424 Mon Sep 17 00:00:00 2001 From: Priscila Oliveira Date: Fri, 27 Feb 2026 11:02:51 +0100 Subject: [PATCH 1/3] fix(langgraph): Call instrumentLangGraph before .compile() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit instrumentLangGraph works by wrapping the .compile() method on a StateGraph to intercept the compilation step and inject tracing. It must be called before .compile() is invoked. The previous example called instrumentLangGraph on the already-compiled graph — by that point the compile step has already happened, so there is no hook point for the SDK to instrument. Also update the surrounding description to reflect that the helper wraps a StateGraph before compilation, not a compiled graph. Co-Authored-By: Claude --- .../common/configuration/integrations/langgraph.mdx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx b/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx index 9a33276fffa1c..308386d01ce6a 100644 --- a/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx +++ b/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx @@ -52,7 +52,7 @@ For meta-framework applications using all runtimes, you need to manually wrap yo _Import name: `Sentry.langGraphIntegration`_ -The `langGraphIntegration` adds instrumentation for [`@langchain/langgraph`](https://www.npmjs.com/package/@langchain/langgraph) to capture spans by automatically wrapping LangGraph operations and recording AI agent interactions including agent invocations, graph executions, and node operations. +The `langGraphIntegration` adds instrumentation for [`@langchain/langgraph`](https://www.npmjs.com/package/@langchain/langgraph) to capture spans by automatically wrapping LangGraph operations and recording AI agent interactions including agent invocations, graph executions, and node operations. @@ -98,7 +98,7 @@ For Cloudflare Workers, manual instrumentation is required using `instrumentLang -The `instrumentLangGraph` helper adds instrumentation for [`@langchain/langgraph`](https://www.npmjs.com/package/@langchain/langgraph) to capture spans by wrapping a compiled LangGraph graph and recording AI agent interactions with configurable input/output recording. You need to manually wrap your compiled graph with this helper. See example below: +The `instrumentLangGraph` helper adds instrumentation for [`@langchain/langgraph`](https://www.npmjs.com/package/@langchain/langgraph) to capture spans by wrapping a `StateGraph` before compilation and recording AI agent interactions with configurable input/output recording. You need to call this helper on the graph **before** calling `.compile()`. See example below: ```javascript import { ChatOpenAI } from "@langchain/openai"; @@ -124,14 +124,14 @@ const agent = new StateGraph(MessagesAnnotation) .addEdge(START, 'agent') .addEdge('agent', END); -const graph = agent.compile({ name: 'my_agent' }); - -// Manually instrument the graph -Sentry.instrumentLangGraph(graph, { +// Instrument the graph before compiling +Sentry.instrumentLangGraph(agent, { recordInputs: true, recordOutputs: true, }); +const graph = agent.compile({ name: 'my_agent' }); + // Invoke the agent const result = await graph.invoke({ messages: [ From fa2f446a74b0b301a91414f9cd7408cc618e98cb Mon Sep 17 00:00:00 2001 From: Priscila Oliveira Date: Fri, 27 Feb 2026 12:44:43 +0100 Subject: [PATCH 2/3] fix(langgraph): Correct alert to say wrap graph before compiling The alert box incorrectly said "wrap your compiled graph", implying instrumentLangGraph should be called post-compilation. It must be called on the StateGraph before .compile(), as stated elsewhere in the doc and shown in the code examples. Co-Authored-By: Claude --- .../javascript/common/configuration/integrations/langgraph.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx b/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx index 308386d01ce6a..5a04747fb0de8 100644 --- a/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx +++ b/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx @@ -42,7 +42,7 @@ supported: -For meta-framework applications using all runtimes, you need to manually wrap your compiled graph with `instrumentLangGraph`. See instructions in the [Browser-Side Usage](#browser-side-usage) section. +For meta-framework applications using all runtimes, you need to manually wrap your graph before compiling with `instrumentLangGraph`. See instructions in the [Browser-Side Usage](#browser-side-usage) section. From 945aed5f3ebed9871b5353b2a54bbeb7a4e49d2c Mon Sep 17 00:00:00 2001 From: Priscila Oliveira Date: Fri, 27 Feb 2026 14:02:20 +0100 Subject: [PATCH 3/3] fix(langgraph): Add missing SystemMessage and HumanMessage import Co-Authored-By: Claude --- .../javascript/common/configuration/integrations/langgraph.mdx | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx b/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx index 5a04747fb0de8..2392badda8651 100644 --- a/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx +++ b/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx @@ -103,6 +103,7 @@ The `instrumentLangGraph` helper adds instrumentation for [`@langchain/langgraph ```javascript import { ChatOpenAI } from "@langchain/openai"; import { StateGraph, MessagesAnnotation, START, END } from '@langchain/langgraph'; +import { SystemMessage, HumanMessage } from '@langchain/core/messages'; // Create LLM call const llm = new ChatOpenAI({