Skip to content

[BUG] Graph运行过程中,节点抛出异常,该节点会被有限的继续执行几次 #2184

@AllenFan4141

Description

@AllenFan4141

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

代码参考: https://github.com/springaialibaba/spring-ai-alibaba-examples/tree/main/spring-ai-alibaba-graph-example/stream-node


GraphProcess graphProcess = new GraphProcess(this.compiledGraph);
      Sinks.Many<ServerSentEvent<String>> sink = Sinks.many().unicast().onBackpressureBuffer();
      AsyncGenerator<NodeOutput> resultFuture = compiledGraph.stream(objectMap, runnableConfig);
      graphProcess.processStream(resultFuture, sink);

public Map<String, Object> apply(OverAllState state) throws Exception {
        String query = state.value("query", "");
        Integer expanderNumber = state.value("expander_number", this.NUMBER);

        Flux<ChatResponse> chatResponseFlux = this.chatClient.prompt().user((user) -> user.text(DEFAULT_PROMPT_TEMPLATE.getTemplate()).param("number", expanderNumber).param("query", query)).stream().chatResponse();

        AsyncGenerator<? extends NodeOutput> generator = StreamingChatGenerator.builder()
                .startingNode("expander_llm_stream")
                .startingState(state)
                .mapResult(response -> {
                    String text = response.getResult().getOutput().getText();
                    List<String> queryVariants = Arrays.asList(text.split("\n"));
                    return Map.of("expander_content", queryVariants);
                }).build(chatResponseFlux);
        throw  new RuntimeException("流程执行出错");
//        return Map.of("expander_content", generator);
    }

当NodeAction.apply 方法中抛出异常 ,会导致该节点不停的被调用,大概20次左右停止, 且不会触发GraphProcess 中的exceptionally 回调

Expected Behavior

希望节点抛出异常后 流程能终止 且能够触发exceptionally 或者

Steps To Reproduce

No response

Environment

Spring AI Alibaba version(s):1.0.0.3

Debug logs

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/graphSAA Grpah modulekind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions