Repository navigation
fix(server-utils): Create an invoke_agent span for LangGraph stream() - #25749
Draft
RulaKhaled wants to merge 4 commits into
Draft
RulaKhaled wants to merge 4 commits into
RulaKhaled wants to merge 4 commits into
Conversation
LangGraph runs the graph as soon as stream() is called, whether or not the stream is read, so the span ends on the run's own end or error callback. A break never reaches those callbacks, so it ends the span too. Co-Authored-By: Seongho.Bak <psh30095@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…lpers Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…allbacks invoke() and stream() now copy the config instead of writing Sentry's metadata and callbacks into the caller's object, and start from the parent run's callbacks when none are passed, as LangChain would. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Optional E2E testsSome optional checks were not successful. They do not block the merge. 3 not successful, 57 successful. See the run.
Successful checks
|
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CompiledGraph.stream()produced nogen_ai.invoke_agentspan, so the chat and tool spans of a streamed run had no agent span above them.LangGraph runs the graph as soon as
stream()is called, whether or not anyone reads it, so the span now follows the run. It ends on the run's ownhandleChainEnd/handleChainError, and the output comes from the final state, the same wayinvoke()records it.invoke()keeps its single span. The shared setup also no longer writes Sentry's metadata and callbacks into the caller's config, and a graph seen by bothinstrumentStateGraph()and the integration is wrapped once, with the manual options winning.Known limitation. When a caller stops reading early, LangGraph keeps running the graph but never reports the run's end. After a
breakthe span ends at the break, so later nodes' spans start after it. Afterreader.cancel()or a client disconnecting fromnew Response(stream), the span never ends.Replaces #23615. Co-authored with @psh4607 from that PR.
Fixes #19626
🤖 Generated with Claude Code