Skip to content

add subagent personal assistant#449

Open
junxwang wants to merge 10 commits into
spring-ai-alibaba:mainfrom
junxwang:main
Open

add subagent personal assistant#449
junxwang wants to merge 10 commits into
spring-ai-alibaba:mainfrom
junxwang:main

Conversation

@junxwang

@junxwang junxwang commented Mar 20, 2026

Copy link
Copy Markdown

What does this PR do?

feat: add subagent personal assistant

背景

本示例展示如何使用 Spring AI Alibaba 的 ReactAgent 框架构建一个多智能体监督者模式系统,通过主智能体协调多个子智能体,实现日历代理与邮件发送功能。

验证方法

  1. 设置 API Key

    export DASHSCOPE_API_KEY=your-api-key
  2. 构建项目

    cd subagent-personal-assistant-example
    mvn clean package -DskipTests
  3. 运行应用

    mvn spring-boot:run
  4. 访问API

curl --location 'http://127.0.0.1:8080/react/agent/supervisorAgent?query=Schedule%20a%20meeting%20with%20the%20design%20team%20next%20Tuesday%20at%202pm%20for%201%20hour%2C%20and%20send%20them%20an%20email%20reminder%20about%20reviewing%20the%20new%20mockups.&threadId=user-session-124&nodeId=_AGENT_HOOK_HITL' \
--header 'Content-Type: application/json' \
--header 'Accept: text/event-stream' \
--data ''

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Spring Boot example module demonstrating a “supervisor + subagents” personal assistant built on Spring AI Alibaba ReactAgent, including calendar/email tooling and a basic HITL (human-in-the-loop) approval flow.

Changes:

  • Introduces a new subagent-personal-assistant-example module with Supervisor/Calendar/Email agents and tool-callback implementations.
  • Adds a streaming REST endpoint to drive the supervisor agent and handle HITL interruptions/resume.
  • Adds module docs/config (README, application.yml, Maven module wiring).

Reviewed changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 14 comments.

Show a summary per file
File Description
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/src/main/resources/application.yml Adds Spring Boot + DashScope model configuration for the new example app.
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/SubAgentPersonalAssistantApplication.java New Spring Boot entrypoint for the example module.
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/config/AgentConfig.java Wires supervisor + subagents, tools, and HITL hook configuration.
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/controller/PersonalAssistantController.java Exposes SSE endpoint for streaming agent output and HITL resume flow.
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/HITLHelper.java Utility helpers to approve/reject/edit tool calls during HITL.
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/tool/UserDataTool.java Tool to lookup users by username/department and return JSON-like results.
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/tool/SendEmailTool.java Tool to validate and simulate sending outbound emails.
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/tool/DateTimeTools.java Tool for returning the current date/time (currently returns date only).
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/tool/CreateCalendarEventTool.java Tool to validate/simulate calendar event creation.
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/tool/AvailableTimeSlotsTool.java Tool to validate input and return mocked available meeting slots.
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/model/UserInfo.java DTO for user lookup tool input/output.
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/model/EmailInfo.java DTO for email tool input.
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/model/CalendarInfo.java DTO for calendar creation tool input.
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/model/AvailableTimeInfo.java DTO for available time slots tool input.
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/README.md Adds usage instructions, tool list, and example conversation.
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/pom.xml New module POM with Spring Boot + agent framework dependencies.
pom.xml Adds the new example module to the root multi-module build.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +74 to +86
if (nodeId != null && TOOL_FEEDBACK_MAP.containsKey(nodeId)) {
System.out.println("人工介入开始...");
// Human intervention using checkpoint mechanism.
// You must provide a thread ID to associate execution with a session thread,
// so that conversations can be paused and resumed (required for human review).
InterruptionMetadata metadata = InterruptionMetadata.builder().toolFeedbacks(TOOL_FEEDBACK_MAP.get(nodeId)).build();
InterruptionMetadata approvalMetadata = HITLHelper.approveAll(metadata);
// Resume execution using approval decision
config = RunnableConfig.builder()
.threadId(threadId) // Same thread ID
.addHumanFeedback(approvalMetadata)
.build();
TOOL_FEEDBACK_MAP.remove(nodeId);

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When resuming from a HITL interruption you rebuild InterruptionMetadata with only toolFeedbacks; nodeId/state are not set, but HITLHelper.approveAll() copies node/state from the provided metadata. This likely produces feedback metadata with null nodeId/state and can break resume execution. Store the original InterruptionMetadata (or at least nodeId + state) in the map and use it when creating the approval metadata.

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在println(NodeOutput nodeOutput) 方法中有存储元数据

Comment thread spring-ai-alibaba-agent-example/subagent-personal-assistant-example/README.md Outdated
Comment thread spring-ai-alibaba-agent-example/subagent-personal-assistant-example/README.md Outdated
Comment thread pom.xml Outdated
Comment on lines +18 to +29
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* @author wangjx
* @since 2026-02-13
*/
@SpringBootApplication
public class SubAgentPersonalAssistantApplication {
public static void main(String[] args) {
SpringApplication.run(SubAgentPersonalAssistantApplication.class, args);
}

Copilot AI Mar 23, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other agent example modules include at least a basic @SpringBootTest contextLoads test, but this new module has no src/test at all (despite depending on spring-boot-starter-test). Adding a minimal context-load test would help catch wiring/config regressions (e.g., bean creation for supervisorAgent).

Copilot uses AI. Check for mistakes.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

当前项目为使用示例,README.md中已提供使用方法,无需在提供 test用例

@junxwang

Copy link
Copy Markdown
Author

@robocanic

@robocanic

robocanic commented Mar 30, 2026

Copy link
Copy Markdown

@robocanic

Working on it. Btw, can you provide the background of this PR and the verification means?

@junxwang

junxwang commented Mar 30, 2026

Copy link
Copy Markdown
Author

@robocanic

正在努力。顺便问一下,你能介绍一下这个永久居民的背景和验证方式吗?

已更新

@junxwang

junxwang commented Apr 22, 2026

Copy link
Copy Markdown
Author

@robocanic 您好,PR #449 已准备就绪,所有检查已通过,麻烦您有空时帮忙合并一下,谢谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants