add subagent personal assistant#449
Conversation
There was a problem hiding this comment.
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-examplemodule 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.
| 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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
在println(NodeOutput nodeOutput) 方法中有存储元数据
...l-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/tool/SendEmailTool.java
Outdated
Show resolved
Hide resolved
...l-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/tool/SendEmailTool.java
Outdated
Show resolved
Hide resolved
...t-example/src/main/java/com/cloud/alibaba/ai/example/agent/tool/CreateCalendarEventTool.java
Show resolved
Hide resolved
...l-assistant-example/src/main/java/com/cloud/alibaba/ai/example/agent/tool/DateTimeTools.java
Outdated
Show resolved
Hide resolved
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/README.md
Outdated
Show resolved
Hide resolved
spring-ai-alibaba-agent-example/subagent-personal-assistant-example/README.md
Outdated
Show resolved
Hide resolved
| 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); | ||
| } |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
当前项目为使用示例,README.md中已提供使用方法,无需在提供 test用例
What does this PR do?
feat: add subagent personal assistant