Skip to content

ref(langchain)!: Move LangChain and LangGraph integrations to @sentry/server-utils - #22962

Draft
nicohrubec wants to merge 1 commit into
ref/move-ai-workers-ai-2from
ref/move-ai-langchain-langgraph-2
Draft

ref(langchain)!: Move LangChain and LangGraph integrations to @sentry/server-utils#22962
nicohrubec wants to merge 1 commit into
ref/move-ai-workers-ai-2from
ref/move-ai-langchain-langgraph-2

Conversation

@nicohrubec

Copy link
Copy Markdown
Member

Move the LangChain and LangGraph gen-ai instrumentation from @sentry/core to @sentry/server-utils/src/ai/{langchain,langgraph}, consuming the shared ai/core base. The public helpers are re-exported from @sentry/server-utils by node/cloudflare/vercel-edge, so the platform SDK public API is unchanged.

LangChain and LangGraph are moved together in one PR because core's LangGraph imports functions and types from LangChain (createLangChainCallbackHandler, normalizeLangChainMessages, _INTERNAL_mergeLangChainCallbackHandler, BaseChatModel/LangChainMessage). Splitting them across PRs would require either a temporary @sentry/core@sentry/server-utils import (the circular dep this whole refactor avoids) or throwaway duplicated code in core. Moving both keeps LangGraph on relative ../langchain imports — the final clean state.

As with the other providers, vercel-edge re-exports from @sentry/server-utils/no-diagnostic-channels to keep the edge build free of node:diagnostics_channel.

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 29.91 kB -0.02% -5 B 🔽
@sentry/browser - with treeshaking flags 28.11 kB -0.02% -4 B 🔽
@sentry/browser (incl. Tracing) 47.35 kB -0.02% -5 B 🔽
@sentry/browser (incl. Tracing + Span Streaming) 47.36 kB -0.01% -4 B 🔽
@sentry/browser (incl. Tracing, Profiling) 52.13 kB -0.01% -5 B 🔽
@sentry/browser (incl. Tracing, Replay) 86.69 kB -0.01% -4 B 🔽
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 76.13 kB -0.01% -4 B 🔽
@sentry/browser (incl. Tracing, Replay with Canvas) 91.41 kB -0.01% -4 B 🔽
@sentry/browser (incl. Tracing, Replay, Feedback) 104.05 kB -0.01% -5 B 🔽
@sentry/browser (incl. Feedback) 47.22 kB -0.02% -5 B 🔽
@sentry/browser (incl. sendFeedback) 34.76 kB -0.02% -5 B 🔽
@sentry/browser (incl. FeedbackAsync) 39.86 kB -0.02% -6 B 🔽
@sentry/browser (incl. Metrics) 30.99 kB -0.02% -5 B 🔽
@sentry/browser (incl. Logs) 31.22 kB -0.02% -4 B 🔽
@sentry/browser (incl. Metrics & Logs) 31.89 kB -0.02% -4 B 🔽
@sentry/react 31.73 kB -0.02% -5 B 🔽
@sentry/react (incl. Tracing) 49.61 kB -0.01% -4 B 🔽
@sentry/vue 34.98 kB -0.03% -7 B 🔽
@sentry/vue (incl. Tracing) 49.34 kB -0.02% -5 B 🔽
@sentry/svelte 29.94 kB -0.02% -5 B 🔽
CDN Bundle 32 kB -0.02% -6 B 🔽
CDN Bundle (incl. Tracing) 47.72 kB -0.02% -6 B 🔽
CDN Bundle (incl. Logs, Metrics) 33.55 kB -0.02% -4 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) 49.08 kB -0.02% -7 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) 72.89 kB -0.01% -5 B 🔽
CDN Bundle (incl. Tracing, Replay) 85.35 kB -0.01% -7 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.65 kB -0.01% -7 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) 91.14 kB -0.01% -5 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.45 kB -0.01% -7 B 🔽
CDN Bundle - uncompressed 95.5 kB -0.03% -24 B 🔽
CDN Bundle (incl. Tracing) - uncompressed 143.08 kB -0.02% -24 B 🔽
CDN Bundle (incl. Logs, Metrics) - uncompressed 100.21 kB -0.03% -24 B 🔽
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 147.06 kB -0.02% -24 B 🔽
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 224.97 kB -0.02% -24 B 🔽
CDN Bundle (incl. Tracing, Replay) - uncompressed 262.34 kB -0.01% -24 B 🔽
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 266.3 kB -0.01% -24 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 276.04 kB -0.01% -24 B 🔽
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 280 kB -0.01% -24 B 🔽
@sentry/nextjs (client) 52.2 kB -0.01% -4 B 🔽
@sentry/sveltekit (client) 47.8 kB -0.02% -8 B 🔽
@sentry/core/server 69.68 kB -12.92% -10.34 kB 🔽
@sentry/core/browser 51.96 kB -0.02% -9 B 🔽
@sentry/node 121.22 kB +0.28% +332 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 0 B added added
@sentry/node - without tracing 84.26 kB -0.01% -5 B 🔽
@sentry/aws-serverless 92.92 kB -0.02% -17 B 🔽
@sentry/cloudflare (withSentry) - minified 224.91 kB +2.53% +5.54 kB 🔺
@sentry/cloudflare (withSentry) 553.2 kB +2.36% +12.73 kB 🔺

View base workflow run

…y/server-utils`

Move the LangChain and LangGraph gen-ai instrumentation from `@sentry/core` to
`@sentry/server-utils/src/ai/{langchain,langgraph}`, consuming the shared `ai/core`
base. The public helpers (`createLangChainCallbackHandler`, `instrumentLangChainEmbeddings`,
`instrumentStateGraph`, `instrumentStateGraphCompile`, `instrumentCreateReactAgent`) are
re-exported from `@sentry/server-utils` by node/cloudflare/vercel-edge, so the platform
SDK public API is unchanged.

LangChain and LangGraph move together because core's LangGraph imports functions and
types from LangChain (`createLangChainCallbackHandler`, `normalizeLangChainMessages`,
`_INTERNAL_mergeLangChainCallbackHandler`, `BaseChatModel`/`LangChainMessage`); splitting
them across PRs would require a temporary core->server-utils import (circular dep) or
duplicated code. Moving both keeps LangGraph on relative `../langchain` imports.

As with the other providers, `vercel-edge` re-exports from
`@sentry/server-utils/no-diagnostic-channels` to keep the edge build free of
`node:diagnostics_channel`.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@nicohrubec
nicohrubec force-pushed the ref/move-ai-langchain-langgraph-2 branch from dd86ee6 to 4355a4a Compare August 3, 2026 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant