-
Notifications
You must be signed in to change notification settings - Fork 259
feat(plan): add changeHook management API to PlanNotebook & add HITL support for plan execution #687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…ecution - Add pause/resume/stop API endpoints in ChatController - Implement stop request and paused state tracking in AgentService - Add hook to pause after plan tool execution when stop requested - Add control buttons (Stop/Continue) and paused indicator in frontend - Handle [PAUSED] marker in SSE stream for UI state management Change-Id: Ib6d1c15ed99f97917d016003e757fb03ba00ecbc Co-developed-by: Qoder CLI <noreply@qoder.com>
Add addChangeHook/removeChangeHook methods to allow external code to register callbacks for plan state changes. Update plan-notebook example to use changeHook for SSE broadcasting instead of manual Hook detection. 🤖 Generated with [Qoder][https://qoder.com] Change-Id: I4c34fb4c1ca90877b0826b213878378b20a32639 Co-developed-by: Qoder CLI <noreply@qoder.com>
Summary of ChangesHello @LearningGp, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces Human-in-the-Loop (HITL) support for plan execution and adds a changeHook management API to PlanNotebook. The changes are well-structured, with a clean new core API and a comprehensive example implementation on both the backend and frontend. The HITL feature is a valuable addition. My review focuses on improving the robustness of the implementation by addressing a few potential race conditions in both the Java service and the frontend JavaScript that could arise from concurrent user actions.
...es/plan-notebook/src/main/java/io/agentscope/examples/plannotebook/service/AgentService.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds Human-in-the-Loop (HITL) pause/resume support to the PlanNotebook web example and exposes a change-hook management API on PlanNotebook to integrate plan state changes with external systems. It wires the new HITL flow through the backend agent service, REST endpoints, and the frontend UI, and introduces public addChangeHook/removeChangeHook methods on PlanNotebook.
Changes:
- Frontend: extend the PlanNotebook UI with a Stop/Continue control button, paused indicator, and a shared SSE response handler that reacts to a
[PAUSED]marker from the backend. - Backend example: update
AgentServiceandChatControllerin the plan-notebook example to support pause/resume via streaming events, track paused/stop-requested state, and expose new HITL-related endpoints. - Core library: add public
addChangeHook(String, BiConsumer<PlanNotebook, Plan>)andremoveChangeHook(String)APIs toPlanNotebookto manage plan change hooks externally.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| agentscope-examples/plan-notebook/src/main/resources/static/index.html | Adds HITL UI elements (Stop/Continue control button, paused indicator), centralizes SSE stream parsing (including a [PAUSED] sentinel), and adjusts chat/plan controls to reflect agent pause/stop state. |
| agentscope-examples/plan-notebook/src/main/java/io/agentscope/examples/plannotebook/service/AgentService.java | Configures a plan change hook on PlanNotebook, introduces atomic pause/stop flags, maps streaming Events (including AGENT_RESULT with ACTING_STOP_REQUESTED) to SSE text, and adds resume, isPaused, requestStop, and isStopRequested methods with state reset logic. |
| agentscope-examples/plan-notebook/src/main/java/io/agentscope/examples/plannotebook/controller/ChatController.java | Extends the chat API with /resume, /paused, /stop, and /stop-requested endpoints to drive the HITL pause/resume flow and expose pause/stop state to the frontend. |
| agentscope-core/src/main/java/io/agentscope/core/plan/PlanNotebook.java | Introduces public addChangeHook/removeChangeHook methods backed by the existing changeHooks map and triggerPlanChangeHooks() pipeline, enabling external consumers to react to plan mutations. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...es/plan-notebook/src/main/java/io/agentscope/examples/plannotebook/service/AgentService.java
Show resolved
Hide resolved
...an-notebook/src/main/java/io/agentscope/examples/plannotebook/controller/ChatController.java
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…ITL flow - Use compareAndSet in AgentService.resume() to prevent concurrent resume calls - Add isProcessing guard in sendMessage/resumeAgent to prevent duplicate requests - Remove explicit broadcastPlanChange() in PlanService to avoid duplicate SSE events - Add HITL API documentation to README - Add unit tests for PlanNotebook changeHook API 🤖 Generated with [Qoder][https://qoder.com] Change-Id: If4c091b437b39a472c06e13855fadce989eff6c3 Co-developed-by: Qoder CLI <noreply@qoder.com>
AgentScope-Java Version
1.0.9
Description
feat(plan-notebook): add Human-in-the-Loop (HITL) support for plan execution
feat(plan): add changeHook management API to PlanNotebook
Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)