feat(examples): add HITL interactive UI example with fitness coach#832
feat(examples): add HITL interactive UI example with fitness coach#832LearningGp wants to merge 6 commits intoagentscope-ai:mainfrom
Conversation
Change-Id: I8be7d0bdc96054674a46def557283a4db75e912f Co-developed-by: Cursor <noreply@cursor.com> Made-with: Cursor
Change-Id: I13783435e448f101c8978c2eaf7fd13ec86091df Co-developed-by: Cursor <noreply@cursor.com> Made-with: Cursor
Change-Id: Id8b10989c811e8ad5ba4bad0a61d09d9ec54af47 Co-developed-by: Cursor <noreply@cursor.com> Made-with: Cursor
Change-Id: I82be21813c101f7639e5a799c89a7c536f52d444 Co-developed-by: Cursor <noreply@cursor.com> Made-with: Cursor
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 introduces a new advanced example demonstrating Human-in-the-Loop (HITL) capabilities within the AgentScope framework. It showcases how an AI fitness coach agent can engage in dynamic, structured interactions with a user through a web-based UI. The example highlights the use of custom tools to request specific user input (e.g., fitness goals, body info) and to seek explicit confirmation for sensitive actions like adding calendar events, thereby enhancing user control and transparency in agent-driven workflows. Highlights
Changelog
Activity
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.
Code Review
This pull request introduces a comprehensive Human-in-the-Loop (HITL) interactive UI example. It adds several new Java classes: AddCalendarEventTool for simulating calendar event additions, UserInteractionTool for dynamic user input, ToolConfirmationHook to intercept tools requiring user approval, and ObservationHook for detailed console logging of agent events. The HitlInteractionExample class orchestrates these components, setting up a ReActAgent and exposing REST endpoints for chat, user responses, session management, and tool confirmation via Server-Sent Events (SSE). The frontend, implemented with app.js, index.html, and style.css, provides a dynamic chat interface that renders various UI components (text, select, form, date, number inputs) based on agent requests and handles user interactions and tool confirmations. Review comments suggest refining error handling in HitlInteractionExample.java by using more specific exception types for ObjectMapper operations, improving code readability in ObservationHook.java by using Java's switch statement with pattern matching, and enhancing type safety in UserInteractionTool.java by explicitly typing defaultValue as String.
...ples/advanced/src/main/java/io/agentscope/examples/advanced/hitl/HitlInteractionExample.java
Show resolved
Hide resolved
...ples/advanced/src/main/java/io/agentscope/examples/advanced/hitl/HitlInteractionExample.java
Show resolved
Hide resolved
...pe-examples/advanced/src/main/java/io/agentscope/examples/advanced/hitl/ObservationHook.java
Show resolved
Hide resolved
...xamples/advanced/src/main/java/io/agentscope/examples/advanced/hitl/UserInteractionTool.java
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
Adds a new advanced example demonstrating HITL (Human-in-the-Loop) interactions via a dynamic, form-driven web UI, including tool-suspension for user input and pre-execution confirmation for “dangerous” tools.
Changes:
- Added a standalone static web UI (HTML/CSS/JS) that streams agent events over SSE and renders dynamic interaction components.
- Added a Spring Boot example backend that streams agent events, suspends on
ask_user, and resumes via/respondand/confirmendpoints. - Added supporting HITL tools and hooks (
ask_user, confirmation hook, observation logging hook).
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 11 comments.
Show a summary per file
| File | Description |
|---|---|
| agentscope-examples/advanced/src/main/resources/static/hitl-interaction/style.css | Styling for the HITL interactive chat UI, tool events, and dynamic interaction cards. |
| agentscope-examples/advanced/src/main/resources/static/hitl-interaction/index.html | Static page shell for the example UI, language toggle, and basic chat controls. |
| agentscope-examples/advanced/src/main/resources/static/hitl-interaction/app.js | Client-side SSE streaming + rendering for messages, tool events, tool confirmation, and dynamic interaction components. |
| agentscope-examples/advanced/src/main/java/io/agentscope/examples/advanced/hitl/UserInteractionTool.java | Defines the ask_user tool that always suspends agent execution to request structured user input. |
| agentscope-examples/advanced/src/main/java/io/agentscope/examples/advanced/hitl/ToolConfirmationHook.java | Stops the agent when configured tools are pending, enabling approve/reject UX. |
| agentscope-examples/advanced/src/main/java/io/agentscope/examples/advanced/hitl/ObservationHook.java | Logs agent conversation and tool I/O for visibility while running the example. |
| agentscope-examples/advanced/src/main/java/io/agentscope/examples/advanced/hitl/HitlInteractionExample.java | Spring Boot app exposing /api/chat, /respond, /confirm, /interrupt, and /session endpoints and mapping agent events to SSE payloads. |
| agentscope-examples/advanced/src/main/java/io/agentscope/examples/advanced/hitl/AddCalendarEventTool.java | Mock “dangerous” tool used to demonstrate confirmation-gated execution. |
agentscope-examples/advanced/src/main/resources/static/hitl-interaction/index.html
Show resolved
Hide resolved
agentscope-examples/advanced/src/main/resources/static/hitl-interaction/index.html
Show resolved
Hide resolved
...ples/advanced/src/main/java/io/agentscope/examples/advanced/hitl/HitlInteractionExample.java
Show resolved
Hide resolved
...pe-examples/advanced/src/main/java/io/agentscope/examples/advanced/hitl/ObservationHook.java
Show resolved
Hide resolved
agentscope-examples/advanced/src/main/resources/static/hitl-interaction/app.js
Show resolved
Hide resolved
agentscope-examples/advanced/src/main/resources/static/hitl-interaction/app.js
Show resolved
Hide resolved
agentscope-examples/advanced/src/main/resources/static/hitl-interaction/index.html
Show resolved
Hide resolved
...ples/advanced/src/main/java/io/agentscope/examples/advanced/hitl/HitlInteractionExample.java
Show resolved
Hide resolved
...xamples/advanced/src/main/java/io/agentscope/examples/advanced/hitl/UserInteractionTool.java
Show resolved
Hide resolved
agentscope-examples/advanced/src/main/resources/static/hitl-interaction/app.js
Show resolved
Hide resolved
Change-Id: Ic04b8faf9501c47ce9a7f79132299e73cbba3006 Co-developed-by: Cursor <noreply@cursor.com> Made-with: Cursor
Change-Id: I8c82b722f1bacd2490b02811d2a4a0ca0ec9f15d Co-developed-by: Cursor <noreply@cursor.com> Made-with: Cursor
AgentScope-Java Version
1.0.10
Description
Added an example to demonstrate the HITL (Human-in-the-Loop) implementations discussed earlier.
FYI, #743
Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)