You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(langgraph): Call instrumentLangGraph before .compile() (#16611)
Fix the `instrumentLangGraph` example in the Browser-Side Usage section
to call the helper **before** `.compile()`, not after.
`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
passed the already-compiled graph, meaning the compile step had already
happened and there was no hook point for the SDK to instrument.
Also updates the surrounding description from "wrapping a compiled
LangGraph graph" to "wrapping a StateGraph before compilation" to match
the correct usage.
Copy file name to clipboardExpand all lines: docs/platforms/javascript/common/configuration/integrations/langgraph.mdx
+8-7Lines changed: 8 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ supported:
42
42
43
43
<Alert>
44
44
45
-
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.
45
+
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.
46
46
47
47
</Alert>
48
48
@@ -52,7 +52,7 @@ For meta-framework applications using all runtimes, you need to manually wrap yo
52
52
53
53
_Import name: `Sentry.langGraphIntegration`_
54
54
55
-
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.
55
+
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,11 +98,12 @@ For Cloudflare Workers, manual instrumentation is required using `instrumentLang
98
98
99
99
</PlatformSection>
100
100
101
-
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:
101
+
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:
102
102
103
103
```javascript
104
104
import { ChatOpenAI } from"@langchain/openai";
105
105
import { StateGraph, MessagesAnnotation, START, END } from'@langchain/langgraph';
0 commit comments