feat: human-in-the-loop (user input)#1420
Conversation
supreme-gg-gg
commented
Mar 3, 2026
- Ask user questions tool [FEATURE] Built-in "question' tool #1415 (added by default)
- Enhancements to the HITL logic (regarding rejection)
Signed-off-by: Jet Chiang <pokyuen.jetchiang-ext@solo.io>
Signed-off-by: Jet Chiang <pokyuen.jetchiang-ext@solo.io>
There was a problem hiding this comment.
Pull request overview
This PR adds two HITL (human-in-the-loop) enhancements: (1) a built-in ask_user tool that lets the agent pose questions to the user with optional predefined choices, and (2) optional rejection reasons for tool approval denials that are passed to the LLM as context.
Changes:
- New
AskUserTool(Python) andAskUserDisplay(React) that use the existingrequest_confirmationplumbing to interrupt execution and collect structured answers from the user - Rejection reason support: UI collects per-tool free-text reasons on rejection; backend reads and attaches them to
ToolConfirmation.payloadso the LLM sees them
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
python/packages/kagent-adk/src/kagent/adk/tools/ask_user_tool.py |
New built-in AskUserTool implementing the two-phase request_confirmation pattern |
python/packages/kagent-adk/src/kagent/adk/types.py |
Appends AskUserTool unconditionally to every agent's tool list |
python/packages/kagent-adk/src/kagent/adk/_agent_executor.py |
Adds ask-user answers extraction/routing in _process_hitl_decision; attaches rejection reasons to ToolConfirmation.payload for batch and uniform denials |
python/packages/kagent-adk/src/kagent/adk/_approval.py |
Changes rejection callback return type from dict to string; includes optional rejection_reason from payload |
python/packages/kagent-core/src/kagent/core/a2a/_hitl.py |
Adds extract_rejection_reasons_from_message and extract_ask_user_answers_from_message helpers |
python/packages/kagent-core/src/kagent/core/a2a/_consts.py |
New constants: KAGENT_HITL_REJECTION_REASONS_KEY, KAGENT_ASK_USER_TOOL_NAME, KAGENT_ASK_USER_ANSWERS_KEY |
python/packages/kagent-core/src/kagent/core/a2a/__init__.py |
Exports new constants and utility functions |
python/packages/kagent-adk/tests/unittests/test_hitl.py |
New tests for rejection with reason, batch per-tool reasons, ask-user answer flow; updates test assertions for string-return rejection |
ui/src/components/chat/AskUserDisplay.tsx |
New React component rendering interactive question chips and free-text input |
ui/src/components/chat/ChatMessage.tsx |
Routes AskUserRequest messages to AskUserDisplay; adds onAskUserSubmit prop |
ui/src/components/chat/ChatInterface.tsx |
Adds handleAskUserSubmit, pendingRejectionReasons state, and rejection-reason propagation in submitDecisions |
ui/src/components/chat/ToolCallDisplay.tsx |
Threads optional reason through onReject callback signature |
ui/src/components/ToolDisplay.tsx |
Adds "Reject" two-step flow (button → textarea → confirm/cancel) with optional reason |
ui/src/lib/messageHandlers.ts |
buildApprovalMessage branches on ask_user name; adds AskUserRequest to OriginalMessageType; skips pending function-response status |
python/packages/kagent-adk/src/kagent/adk/_memory_service.py |
Adds gemini provider case to the LiteLLM model identifier builder |
docs/architecture/human-in-the-loop.md |
Documents new "Rejection Reasons" and "Ask-User Tool" enhancements |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Signed-off-by: Jet Chiang <pokyuen.jetchiang-ext@solo.io>
|
2 quick things:
|
Signed-off-by: Jet Chiang <pokyuen.jetchiang-ext@solo.io>
yea fixed 2, skipped showing ask user function call. For 1 do you have any specific ideas for what we need for better UX? I mainly copied the design from open code / claudecode where there's multi-select, single-select, or type your own option. |
Sorry, I meant UI, not UX, the feature makes sense as written |
