fix: bubble up subagent HITL approval to parent agent#1478
Open
jsonmp-k8 wants to merge 1 commit intokagent-dev:mainfrom
Open
fix: bubble up subagent HITL approval to parent agent#1478jsonmp-k8 wants to merge 1 commit intokagent-dev:mainfrom
jsonmp-k8 wants to merge 1 commit intokagent-dev:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses subagent “human-in-the-loop” (HITL) deadlocks by detecting when a RemoteA2aAgent subagent enters input-required, surfacing that approval request to the top-level task, and forwarding the user’s decision back to the subagent on resume.
Changes:
- Detect subagent
input-requiredvia ADK eventcustom_metadata["a2a:response"]and persist subagent HITL context in session state. - On HITL resume, route the decision to the subagent over its A2A client, then re-run the parent agent to continue.
- Add unit tests for the new helper methods used for subagent HITL detection/message extraction.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
python/packages/kagent-adk/src/kagent/adk/_agent_executor.py |
Adds subagent HITL detection, session-state persistence, and resume forwarding logic for RemoteA2aAgent. |
python/packages/kagent-adk/tests/unittests/test_hitl.py |
Adds unit tests for subagent HITL helper methods. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When subagents with HITL-enabled tools enter input_required state, the parent agent now detects this from the A2A response metadata and propagates the approval request to the top-level chat. On resume, the decision is forwarded directly to the subagent via its A2A client, and the parent agent re-runs to process the result. Key implementation details: - Detect subagent input_required via ADK event custom_metadata - Persist subagent HITL context in session state for resume - Forward decisions to subagents with 5-minute timeout - Clear HITL state after successful forwarding - Use SubagentForwardResult NamedTuple for type-safe return values - Extract shared helpers to avoid code duplication - Prefer public APIs with private API fallbacks for forward compat - Emit terminal failure events for all error paths - Add comprehensive unit tests for all helper methods Fixes kagent-dev#1475 Signed-off-by: Jaison Paul <paul.jaison@gmail.com>
0484fda to
40cec79
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When subagents with HITL-enabled tools enter input_required state, the parent agent now detects this from the A2A response metadata and propagates the approval request to the top-level chat. On resume, the decision is forwarded directly to the subagent via its A2A client, and the parent agent re-runs to process the result.
Key implementation details:
Fixes #1475