fix: extract subgraph result from GraphResponse in parallel execution (#4516)#4524
Open
4yDX3906 wants to merge 1 commit intoalibaba:mainfrom
Open
fix: extract subgraph result from GraphResponse in parallel execution (#4516)#45244yDX3906 wants to merge 1 commit intoalibaba:mainfrom
4yDX3906 wants to merge 1 commit intoalibaba:mainfrom
Conversation
…alibaba#4516) When subgraphs run in parallel via ParallelNode, the handleParallelGraphFlux method was storing raw GraphResponse objects into the parent state instead of extracting the actual subgraph result data from GraphResponse.resultValue(). Since GraphResponse.output is annotated with @JsonIgnore, this caused the parent state to show empty '{}' for subgraph keys like subgraph_*_compiled_graph. The fix checks if the collected nodeData is a GraphResponse with a resultValue (the subgraph's final state map), and if so, merges it into the parent state using OverAllState.updateState() with proper key strategies — mirroring the extraction logic already used in processGraphResponseFlux for non-parallel subgraph execution. Closes alibaba#4516
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.
Summary
Fixes #4516
When a parent graph executes subgraphs in parallel, the subgraph output is lost — the parent state shows empty
{}for keys likesubgraph_*_compiled_graph.Problem
In
NodeExecutor.handleParallelGraphFlux(), the completion handler collects results from each parallelGraphFluxstream and stores them intocombinedResultMap. However, the collectednodeDatais a rawGraphResponseobject (specificallyGraphResponse.done(subgraphFinalStateMap)). SinceGraphResponse.outputis annotated with@JsonIgnore, storing it directly into the parent state causes serialization to produce empty{}.The non-parallel subgraph path (
processGraphResponseFlux) correctly extracts the actual state data viadata.resultValue()— but this extraction was missing in the parallel path.Solution
In the result collection loop of
handleParallelGraphFlux, added a check: whennodeDatais aGraphResponsewith aresultValuepresent and of typeMap, extract the map and merge it intocombinedResultMapusingOverAllState.updateState()with proper key strategies. This mirrors the extraction logic already used inprocessGraphResponseFlux.Changes
NodeExecutor.java(handleParallelGraphFlux): Extract subgraph final state fromGraphResponse.resultValue()instead of storing the rawGraphResponseobjectTesting
spring-ai-alibaba-graph-corepass (0 failures, 0 errors)SubGraphTest(12 tests) — includingtestParallelSubgraphStateGraphParallelTest(7 tests)CompiledSubGraphTest(4 tests)