Python: extend HITL support for all orchestration patterns#2620
Merged
TaoChenOSU merged 10 commits intomicrosoft:mainfrom Dec 10, 2025
Merged
Python: extend HITL support for all orchestration patterns#2620TaoChenOSU merged 10 commits intomicrosoft:mainfrom
TaoChenOSU merged 10 commits intomicrosoft:mainfrom
Conversation
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends Human-In-The-Loop (HITL) support to all major orchestration patterns by introducing a unified .with_human_input_hook() API. The implementation adds a new HumanInputHookMixin that enables SequentialBuilder, ConcurrentBuilder, GroupChatBuilder, and HandoffBuilder to pause workflows and request arbitrary human feedback mid-execution, while MagenticBuilder retains its specialized HITL mechanisms due to internal architectural constraints.
Key Changes:
- Introduced
HumanInputRequestdata type andHumanInputHookMixinfor builder-agnostic human input hooks - Added
_HumanInputInterceptorexecutor that intercepts agent responses and invokes configurable hooks - Extended all high-level builders (except MagenticBuilder) with the mixin for consistent HITL API
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
_human_input.py |
New module providing HumanInputRequest, HumanInputHookMixin, and _HumanInputInterceptor for unified HITL support |
_sequential.py |
Added HumanInputHookMixin to SequentialBuilder, inserting interceptors between agents and response converters |
_concurrent.py |
Added HumanInputHookMixin to ConcurrentBuilder, inserting interceptor between fan-in and aggregator |
_group_chat.py |
Added HumanInputHookMixin to GroupChatBuilder, wrapping participant pipelines with interceptors and extracting trailing user messages |
_handoff.py |
Added HumanInputHookMixin to HandoffBuilder with agent ID extraction logic for interceptor prefixes |
_magentic.py |
Added documentation explaining MagenticBuilder's specialized HITL mechanisms; accidental regex change detected |
__init__.py |
Exported new public API: HumanInputHook, HumanInputHookMixin, HumanInputHookResult, HumanInputRequest |
test_human_input_hook.py |
Unit tests for HumanInputRequest, HumanInputHookMixin, and _HumanInputInterceptor |
test_handoff.py |
Tests verifying HandoffBuilder supports human input hook with method chaining |
test_magentic.py |
Test confirming MagenticBuilder correctly lacks generic human input hook |
sequential_builder_tool_approval.py |
Sample demonstrating tool approval with SequentialBuilder using @ai_function decorator |
concurrent_builder_tool_approval.py |
Sample demonstrating tool approval with ConcurrentBuilder across parallel agents |
group_chat_builder_tool_approval.py |
Sample demonstrating tool approval with GroupChatBuilder in multi-agent collaboration |
sequential_human_input_hook.py |
Sample demonstrating custom human input hook with SequentialBuilder for mid-workflow feedback |
concurrent_human_input_hook.py |
Sample demonstrating human input hook with ConcurrentBuilder for reviewing concurrent outputs |
group_chat_human_input_hook.py |
Sample demonstrating human input hook with GroupChatBuilder for steering group discussions |
README.md |
Updated with new HITL and tool-approval sample sections |
SAMPLE_GUIDELINES.md |
Updated guideline to place sample docstrings underneath imports rather than at top of file |
eavanvalkenburg
approved these changes
Dec 4, 2025
TaoChenOSU
reviewed
Dec 4, 2025
python/packages/core/agent_framework/_workflows/_human_input.py
Outdated
Show resolved
Hide resolved
python/packages/core/agent_framework/_workflows/_human_input.py
Outdated
Show resolved
Hide resolved
python/packages/core/agent_framework/_workflows/_human_input.py
Outdated
Show resolved
Hide resolved
python/packages/core/agent_framework/_workflows/_human_input.py
Outdated
Show resolved
Hide resolved
python/packages/core/agent_framework/_workflows/_human_input.py
Outdated
Show resolved
Hide resolved
python/packages/core/agent_framework/_workflows/_human_input.py
Outdated
Show resolved
Hide resolved
TaoChenOSU
reviewed
Dec 9, 2025
python/packages/core/agent_framework/_workflows/_orchestration_request_info.py
Outdated
Show resolved
Hide resolved
python/packages/core/agent_framework/_workflows/_orchestration_request_info.py
Show resolved
Hide resolved
python/packages/core/agent_framework/_workflows/_orchestration_request_info.py
Show resolved
Hide resolved
TaoChenOSU
approved these changes
Dec 10, 2025
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
…#2620) * Support HITL for orchestration patterns * Cleanup around naming * Fix typing issues * Clean up * Naming clean up * Updates to HITL to make it cleaner * Rename human input hook to orchestration request info * Clean up per PR feedback
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.
Motivation and Context
The high-level orchestration builders lacked a consistent human-in-the-loop (HITL) API. Developers needed different approaches for each pattern to intercept agent responses and request human input mid-workflow.
Added
HumanInputHookMixinsupport toSequentialBuilder,ConcurrentBuilder,GroupChatBuilder, andHandoffBuilder. All patterns now expose a unified.with_human_input_hook()method that accepts a callback invoked after each agent response, enabling workflows to pause and request human input when needed.MagenticBuilderretains its specialized HITL mechanisms (with_plan_review(),with_human_input_on_stall()) due to internal message type constraints.Description
Important
I will update the Learn Site docs once this PR goes in.
Contribution Checklist