Commit abe4733
authored
fix(gettingStartedDocs): Update LangGraph example to use StateGraph API (#109551)
Update the LangGraph code snippet in the agent monitoring getting
started guide.
`instrumentLangGraph` works by wrapping the `.compile()` method on a
`StateGraph` to intercept the compilation step and inject tracing. This
means it must be called before `.compile()` is invoked.
`createReactAgent` calls `.compile()` internally and returns the
already-compiled graph — there's no hook point between graph
construction and compilation. By the time you get the return value, the
compile step has already happened, making it too late for
`instrumentLangGraph` to do its job.
In short: `createReactAgent` hides the compile step, but
`instrumentLangGraph` needs to wrap that exact step. They are
fundamentally incompatible with the current SDK API.
The fix replaces `createReactAgent` with the lower-level `StateGraph` +
`MessagesAnnotation` pattern, which keeps the compile step explicit and
accessible.1 parent 2a61d42 commit abe4733
1 file changed
Lines changed: 11 additions & 3 deletions
Lines changed: 11 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
119 | | - | |
| 119 | + | |
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
| |||
125 | 125 | | |
126 | 126 | | |
127 | 127 | | |
128 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
129 | 135 | | |
130 | | - | |
| 136 | + | |
131 | 137 | | |
132 | 138 | | |
133 | 139 | | |
134 | 140 | | |
| 141 | + | |
| 142 | + | |
135 | 143 | | |
136 | 144 | | |
137 | 145 | | |
| |||
0 commit comments