Skip to content

fix: bubble up subagent HITL approval to parent agent#1478

Open
jsonmp-k8 wants to merge 1 commit intokagent-dev:mainfrom
jsonmp-k8:fix/subagent-hitl-stuck
Open

fix: bubble up subagent HITL approval to parent agent#1478
jsonmp-k8 wants to merge 1 commit intokagent-dev:mainfrom
jsonmp-k8:fix/subagent-hitl-stuck

Conversation

@jsonmp-k8
Copy link
Contributor

@jsonmp-k8 jsonmp-k8 commented Mar 11, 2026

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 #1475

Copilot AI review requested due to automatic review settings March 11, 2026 04:09
Copy link
Contributor

Copilot AI left a 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 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-required via ADK event custom_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>
@jsonmp-k8 jsonmp-k8 force-pushed the fix/subagent-hitl-stuck branch from 0484fda to 40cec79 Compare March 11, 2026 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Subagents get stuck when using human in the loop

2 participants