Skip to content

fix: extract subgraph result from GraphResponse in parallel execution (#4516)#4524

Open
4yDX3906 wants to merge 1 commit intoalibaba:mainfrom
4yDX3906:fix/issue-4516
Open

fix: extract subgraph result from GraphResponse in parallel execution (#4516)#4524
4yDX3906 wants to merge 1 commit intoalibaba:mainfrom
4yDX3906:fix/issue-4516

Conversation

@4yDX3906
Copy link
Copy Markdown
Contributor

@4yDX3906 4yDX3906 commented Apr 8, 2026

Summary

Fixes #4516

When a parent graph executes subgraphs in parallel, the subgraph output is lost — the parent state shows empty {} for keys like subgraph_*_compiled_graph.

Problem

In NodeExecutor.handleParallelGraphFlux(), the completion handler collects results from each parallel GraphFlux stream and stores them into combinedResultMap. However, the collected nodeData is a raw GraphResponse object (specifically GraphResponse.done(subgraphFinalStateMap)). Since GraphResponse.output is 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 via data.resultValue() — but this extraction was missing in the parallel path.

Solution

In the result collection loop of handleParallelGraphFlux, added a check: when nodeData is a GraphResponse with a resultValue present and of type Map, extract the map and merge it into combinedResultMap using OverAllState.updateState() with proper key strategies. This mirrors the extraction logic already used in processGraphResponseFlux.

Changes

  • NodeExecutor.java (handleParallelGraphFlux): Extract subgraph final state from GraphResponse.resultValue() instead of storing the raw GraphResponse object

Testing

  • All 288 existing tests in spring-ai-alibaba-graph-core pass (0 failures, 0 errors)
  • SubGraphTest (12 tests) — including testParallelSubgraph
  • StateGraphParallelTest (7 tests)
  • CompiledSubGraphTest (4 tests)

…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
@github-actions github-actions bot added the area/graph SAA Grpah module label Apr 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/graph SAA Grpah module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 父图【并行】执行子图的时候,没有结果(output)输出

1 participant