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
{{ message }}
Repository navigation
LangChain: explicit callback handler produces flat spans and drops the conversation id on chain and tool spans #25327
Found while writing the test in #25326. Both show up with `Sentry.createLangChainCallbackHandler()` passed explicitly, and both behave the same on `@langchain/core` 1.2.16 and 1.2.17.
Flat spans. A runnable that calls a tool, which then runs a nested chain and model, produces `invoke_agent outer`, `execute_tool lookup_weather`, `invoke_agent nested_chain` and the chat span as siblings under the caller's span. The handler ignores `parentRunId` and parents each span to whatever span is active, and the run spans it starts never become active. The trace loses which tool made which model call.
No conversation id on chain and tool spans. `handleChainStart` and `handleToolStart` read `gen_ai.conversation.id` from run metadata. Since core 1.1.40, `configurable` is only copied into metadata for LangSmith tracers, so on 1.x those spans never get `thread_id` or `sessionId`. Chat spans still get it, because the integration copies the id onto the model call options (`getConversationIdMetadataFromConfig`).
The scenario in #25326 (`suites/tracing/langchain/v1/scenario-nested-runtime-context.mjs`) reproduces both.
Activity
linear-code commentedon Oct 13, 2026
JS-3926
fix(server-utils): Nest LangChain run spans under their parent run