[BREAKING] Python: Adjust magentic event types raised. No need for custom events.#2215
Merged
moonbox3 merged 6 commits intomicrosoft:mainfrom Nov 25, 2025
Merged
[BREAKING] Python: Adjust magentic event types raised. No need for custom events.#2215moonbox3 merged 6 commits intomicrosoft:mainfrom
moonbox3 merged 6 commits intomicrosoft:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR refactors the Magentic orchestration pattern to eliminate custom event types (MagenticOrchestratorMessageEvent, MagenticAgentDeltaEvent, MagenticAgentMessageEvent, MagenticFinalResultEvent) and instead emit standard AgentRunUpdateEvent objects with metadata to distinguish event types. This allows workflows to work seamlessly as agents and unifies the event handling pattern across the framework.
Key changes:
- Replaced custom Magentic event types with
AgentRunUpdateEventcontaining metadata fields (magentic_event_type,orchestrator_message_kind,agent_id) - Exported new constants (
MAGENTIC_EVENT_TYPE_AGENT_DELTA,MAGENTIC_EVENT_TYPE_ORCHESTRATOR,ORCH_MSG_KIND_*) for event type identification - Updated sample code to use metadata-based event handling instead of type checking custom events
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| python/packages/core/agent_framework/_workflows/_magentic.py | Core implementation: removes custom event classes and emits AgentRunUpdateEvent with metadata; updates documentation |
| python/packages/core/agent_framework/_workflows/init.py | Exports new event type constants and removes custom event types from public API |
| python/packages/core/agent_framework/_workflows/init.pyi | Updates type stubs to reflect new constants and removed event types |
| python/packages/core/agent_framework/_workflows/_agent.py | Updates documentation to clarify that workflow-internal events are ignored |
| python/packages/core/tests/workflow/test_magentic.py | Updates test to handle AgentRunUpdateEvent instead of MagenticAgentMessageEvent; re-enables previously skipped tests |
| python/samples/getting_started/workflows/orchestration/magentic_human_plan_update.py | Updates sample to use AgentRunUpdateEvent with metadata checks instead of custom event types |
| python/samples/getting_started/workflows/agents/magentic_workflow_as_agent.py | Simplifies sample to demonstrate workflow-as-agent pattern using metadata-based event handling |
Member
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
eavanvalkenburg
approved these changes
Nov 18, 2025
TaoChenOSU
approved these changes
Nov 24, 2025
eavanvalkenburg
approved these changes
Nov 25, 2025
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
…stom events. (microsoft#2215) * Adjust magentic event types raised. No need for custom events. * Cleanup * Fix test * Update python/packages/core/agent_framework/_workflows/_magentic.py Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
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
Right now there are custom even types raised from the magentic orchestration pattern. These aren't needed, and aren't actually picked up/raised to the caller while running the workflow as an agent. Since the orchestration pattern uses agents, we should simply yield the underlying agent types to the caller. To help distinguish what is going on in the magentic flow, metadata around the event type is added to the AgentRunResponseUpdate.
Caution
No rush in merging this - fine to do after Ignite because it's breaking.
Important
Once this is in, I will update the learn site docs.
Description
as_agent()doesn't raise custom events #2213Contribution Checklist