Skip to content

Python: Add executor I/O data to ExecutorInvokedEvent and ExecutorCompletedEvent#2591

Merged
moonbox3 merged 4 commits intomicrosoft:mainfrom
moonbox3:2536-address
Dec 4, 2025
Merged

Python: Add executor I/O data to ExecutorInvokedEvent and ExecutorCompletedEvent#2591
moonbox3 merged 4 commits intomicrosoft:mainfrom
moonbox3:2536-address

Conversation

@moonbox3
Copy link
Contributor

@moonbox3 moonbox3 commented Dec 3, 2025

Motivation and Context

Enables observing executor input/output without modifying executor code:

  • ExecutorInvokedEvent.data now contains the input message received by the executor
  • ExecutorCompletedEvent.data now contains messages sent via ctx.send_message()
  • Added WorkflowContext.get_sent_messages() to track sent messages during handler execution

This aligns Python behavior with .NET, where these events already carry I/O data.

Description

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@moonbox3 moonbox3 self-assigned this Dec 3, 2025
Copilot AI review requested due to automatic review settings December 3, 2025 03:38
@moonbox3 moonbox3 added python squad: workflows Agent Framework Workflows Squad workflows Related to Workflows in agent-framework labels Dec 3, 2025
@github-actions github-actions bot changed the title Add executor I/O data to ExecutorInvokedEvent and ExecutorCompletedEvent Python: Add executor I/O data to ExecutorInvokedEvent and ExecutorCompletedEvent Dec 3, 2025
@markwallace-microsoft markwallace-microsoft added the documentation Improvements or additions to documentation label Dec 3, 2025
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Dec 3, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework/_workflows
   _executor.py142695%208, 326, 341, 343, 458, 468
   _workflow_context.py1682684%60–61, 69, 73, 87, 163, 188, 298, 403, 412, 417, 438–440, 442, 444–445, 447–448, 457–459, 461–463, 465
TOTAL15891241684% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2286 130 💤 0 ❌ 0 🔥 58.509s ⏱️

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 adds executor input/output data to workflow events, enabling observability of executor I/O without modifying executor code. The implementation tracks messages sent via ctx.send_message() and exposes them through ExecutorInvokedEvent.data and ExecutorCompletedEvent.data, aligning Python behavior with the .NET implementation.

Key changes:

  • Added WorkflowContext._sent_messages tracking and get_sent_messages() method to capture messages sent during handler execution
  • Updated ExecutorInvokedEvent to include the input message as event data
  • Updated ExecutorCompletedEvent to include sent messages as event data (or None if no messages were sent)

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
python/samples/getting_started/workflows/observability/executor_io_observation.py New sample demonstrating executor I/O observation through streaming events with two executors and helper formatting function
python/samples/getting_started/workflows/README.md Added documentation entry for the new executor I/O observation sample
python/packages/core/tests/workflow/test_handoff.py Improved test robustness by using explicit AgentRunEvent type check and removing fragile attribute checks
python/packages/core/tests/workflow/test_executor.py Added comprehensive unit tests covering input data in invoked events, sent messages in completed events, and complex message types
python/packages/core/agent_framework/_workflows/_workflow_context.py Implemented _sent_messages tracking in send_message() and added get_sent_messages() method; added type ignore comment to existing deprecated method
python/packages/core/agent_framework/_workflows/_executor.py Updated executor event creation to include input message in ExecutorInvokedEvent and sent messages in ExecutorCompletedEvent

@moonbox3 moonbox3 added this pull request to the merge queue Dec 4, 2025
Merged via the queue into microsoft:main with commit f7a9005 Dec 4, 2025
24 checks passed
arisng pushed a commit to arisng/agent-framework that referenced this pull request Feb 2, 2026
…pletedEvent (microsoft#2591)

* Add executor I/O data to ExecutorInvokedEvent and ExecutorCompletedEvent

* Sample cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation python squad: workflows Agent Framework Workflows Squad workflows Related to Workflows in agent-framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: Executor with decorator doesn't generate AgentRunUpdateEvent event

5 participants