Python [BREAKING]: support magentic agent tool call approvals and plan stalling HITL behavior#2569
Merged
moonbox3 merged 8 commits intomicrosoft:mainfrom Dec 4, 2025
Merged
Conversation
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces breaking changes to support Human-in-the-Loop (HITL) capabilities in Magentic workflows, unifying the intervention mechanism and changing the StandardMagenticManager API.
Key Changes:
- Unified human intervention types (
MagenticHumanInterventionRequest/Reply) replace separate plan review types, supporting plan review, tool approvals, and stall interventions - StandardMagenticManager now accepts an
agentparameter instead ofchat_client, allowing the agent's configured options (temperature, seed, instructions) to be applied - New
.with_human_input_on_stall()builder method enables human intervention when workflows stall instead of automatic replanning
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| python/packages/core/agent_framework/_workflows/_magentic.py | Core implementation: unified intervention types, StandardMagenticManager refactored to use AgentProtocol, MagenticOrchestratorExecutor adds stall intervention, MagenticAgentExecutor adds tool approval handling |
| python/packages/core/agent_framework/_workflows/init.py | Updated exports: removed old plan review types, added new unified intervention types and backward compatibility aliases |
| python/packages/core/tests/workflow/test_magentic.py | Updated test stubs and assertions to use new unified types and agent-based StandardMagenticManager |
| python/samples/getting_started/workflows/orchestration/magentic_human_replan.py | New sample demonstrating stall intervention with .with_human_input_on_stall() |
| python/samples/getting_started/workflows/orchestration/magentic_agent_clarification.py | New sample showing agent tool call approvals via @ai_function(approval_mode="always_require") |
| python/samples/getting_started/workflows/orchestration/magentic_human_plan_update.py | Updated to use unified intervention types with extended decision options (approve with comments, edit plan) |
| python/samples/getting_started/workflows/orchestration/magentic_checkpoint.py | Updated to use agent parameter and unified intervention types |
| python/samples/getting_started/workflows/orchestration/magentic.py | Updated to use agent parameter for StandardMagenticManager |
| python/samples/getting_started/workflows/agents/magentic_workflow_as_agent.py | Updated to use agent parameter for StandardMagenticManager |
| python/samples/semantic-kernel-migration/orchestrations/magentic.py | Updated to use agent parameter for StandardMagenticManager |
| python/samples/getting_started/workflows/README.md | Added documentation entries for the two new sample files |
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
dmytrostruk
approved these changes
Dec 4, 2025
victordibia
approved these changes
Dec 4, 2025
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
…n stalling HITL behavior (microsoft#2569) * Provide way for HITL with magentic * support tool call approvals and hitl stall replan * human plan intervention sample * Clean up * Improve loging * updates
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
There are two areas of improvement related to HITL + Magentic workflows:
Right now, there's no way to provide HITL feedback as part of invoking an agent. To handle this, a dev can provide a tool with
@ai_function(approval_mode="always_require"). This will then allow the dev to handle aRequestInfoEventfor a tool approval. The input is provided viaMagenticHumanInterventionReply.If a plan begins to fall off track, we have the option to do an auto replan, depending upon how the
max_stall_countis configured. There's a new API that, instead of simply running auto replan, allows one to configure.with_human_input_on_stall()which will then kick it back to the human to help get the agents back on track.As part of this work, the Magentic standard manager's chat client was updated to use the agent protocol. This aligns better with the pattern in the group chat orchestration, where it also accepts an agent.
Description
Contribution Checklist