Skip to content

[BUG] ReactAgent returnDirect错误 #4427

@wmaozhi

Description

@wmaozhi

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

private EdgeAction makeToolsToModelEdge(String modelDestination, String endDestination) {
	return state -> {
		// 1. Extract last AI message and corresponding tool messages
		ToolResponseMessage toolResponseMessage = fetchLastToolResponseMessage(state);
		// 2. Exit condition: All executed tools have return_direct=True
		if (toolResponseMessage != null && !toolResponseMessage.getResponses().isEmpty()) {
			boolean allReturnDirect = toolResponseMessage.getResponses().stream().allMatch(toolResponse -> {
				String toolName = toolResponse.name();
				return false; // FIXME
			});
			if (allReturnDirect) {
				return endDestination;
			}
		}

		// 3. Default: Continue the loop
		//    Tool execution completed successfully, route back to the model
		//    so it can process the tool results and decide the next action.
		return modelDestination;
	};
}

我有一个tool设置为returnDirect,第一次调用时,工具内容可以直接返回,第二次再调用(会话保持一致)时,会直接检测历史消息包含了returnDirect,调用end节点.导致不经过大模型节点

Expected Behavior

No response

Steps To Reproduce

No response

Environment

Spring AI Alibaba version(s):

Debug logs

No response

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions