Skip to content

[BREAKING] Python: Refactor workflows kwargs#5010

Merged
TaoChenOSU merged 10 commits into
microsoft:mainfrom
TaoChenOSU:taochen/python-refactor-workflows-kwargs
Apr 2, 2026
Merged

[BREAKING] Python: Refactor workflows kwargs#5010
TaoChenOSU merged 10 commits into
microsoft:mainfrom
TaoChenOSU:taochen/python-refactor-workflows-kwargs

Conversation

@TaoChenOSU
Copy link
Copy Markdown
Contributor

@TaoChenOSU TaoChenOSU commented Mar 31, 2026

Motivation and Context

Closes #4850

Description

This is considered breaking even with backward compatibility because it no longer supports passing runtime options to the agents.

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.

@TaoChenOSU TaoChenOSU self-assigned this Mar 31, 2026
@TaoChenOSU TaoChenOSU added python workflows Related to Workflows in agent-framework labels Mar 31, 2026
@github-actions github-actions Bot changed the title Refactor workflows kwargs Python: Refactor workflows kwargs Mar 31, 2026
@TaoChenOSU TaoChenOSU moved this to In Review in Agent Framework Mar 31, 2026
@markwallace-microsoft
Copy link
Copy Markdown
Contributor

markwallace-microsoft commented Mar 31, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/core/agent_framework
   _evaluation.py6277388%159, 167, 476, 478, 604, 607, 686–688, 693, 730–733, 789–790, 793, 799–801, 805, 838–840, 894, 929, 941–943, 948, 972–977, 1068, 1146–1147, 1149–1153, 1159, 1198, 1543, 1545, 1553, 1563, 1567, 1612, 1630–1631, 1702, 1708, 1723, 1727–1729, 1759, 1765–1769, 1801, 1832–1833, 1835, 1860–1861, 1866
packages/core/agent_framework/_workflows
   _agent.py3597080%66, 74–80, 116–117, 214, 277, 279, 348, 350, 410, 416, 426–427, 434, 436, 442, 504–505, 514, 521, 547, 580–582, 584, 586, 588, 593, 598, 645, 675, 692, 731–734, 740, 746, 750–751, 754–760, 764–765, 773, 834, 841, 847–848, 859, 891, 898, 919, 928, 932, 934–936, 943
   _agent_executor.py1871591%109, 133, 174, 200–201, 281–283, 285, 295–296, 401–402, 474, 480
   _const.py70100% 
   _workflow.py2801993%88, 267–269, 271–272, 290, 294, 441, 636, 657, 713, 725, 731, 736, 756–758, 809
   _workflow_executor.py1873183%94, 404, 464, 487, 489, 497–498, 503, 505, 510, 512, 565, 593–599, 603–605, 613, 618, 629, 639, 643, 649, 653, 663, 667
TOTAL27003318888% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
5348 20 💤 0 ❌ 0 🔥 1m 24s ⏱️

@TaoChenOSU TaoChenOSU marked this pull request as ready for review March 31, 2026 21:56
Copilot AI review requested due to automatic review settings March 31, 2026 21:56
Copy link
Copy Markdown
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

Refactors Python workflow run() kwarg handling by introducing explicit function_invocation_kwargs / client_invocation_kwargs routing (including per-executor targeting) and updating samples/tests to reflect the new model, as part of removing legacy workflow-kwargs compatibility paths (Issue #4850).

Changes:

  • Add per-executor/global resolution for function_invocation_kwargs and client_invocation_kwargs and plumb them through workflow state → executors → agents.
  • Update workflow state-management samples to demonstrate global vs per-agent targeting.
  • Adjust workflow/executor tests to validate new routing behavior and logging.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
python/samples/03-workflows/state-management/workflow_kwargs.py Removes old sample demonstrating legacy kwargs flow.
python/samples/03-workflows/state-management/workflow_kwargs_per_agent.py New sample showing per-agent (per-executor-id) function_invocation_kwargs.
python/samples/03-workflows/state-management/workflow_kwargs_global.py New sample showing global function_invocation_kwargs delivery to all agents.
python/packages/core/tests/workflow/test_workflow_kwargs.py Updates/extends tests for new invocation kwargs behavior, removes options-merging coverage.
python/packages/core/tests/workflow/test_agent_executor.py Updates _prepare_agent_run_args tests and adds executor-kwargs resolution tests.
python/packages/core/agent_framework/_workflows/_workflow.py Adds new invocation kwargs params, state persistence, and resolution logic.
python/packages/core/agent_framework/_workflows/_const.py Introduces GLOBAL_KWARGS_KEY="__global__" sentinel.
python/packages/core/agent_framework/_workflows/_agent_executor.py Extracts invocation kwargs from workflow state and routes per-executor/global into agent.run().
python/packages/core/agent_framework/_evaluation.py Minor formatting-only changes.

Comment thread python/packages/core/agent_framework/_workflows/_workflow.py Outdated
Comment thread python/packages/core/agent_framework/_workflows/_workflow.py Outdated
Comment thread python/packages/core/agent_framework/_workflows/_workflow.py Outdated
Comment thread python/packages/core/agent_framework/_workflows/_agent_executor.py Outdated
Comment thread python/packages/core/tests/workflow/test_agent_executor.py Outdated
Copy link
Copy Markdown
Member

@eavanvalkenburg eavanvalkenburg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good overall, couple of comments

Comment thread python/packages/core/agent_framework/_workflows/_agent_executor.py Outdated
Comment thread python/packages/core/agent_framework/_workflows/_agent_executor.py
Comment thread python/packages/core/agent_framework/_workflows/_workflow.py Outdated
Comment thread python/packages/core/agent_framework/_workflows/_workflow.py Outdated
Comment thread python/packages/core/agent_framework/_workflows/_agent.py Outdated
Comment thread python/packages/core/agent_framework/_workflows/_workflow_executor.py Outdated
Comment thread python/packages/core/agent_framework/_workflows/_agent_executor.py Outdated
@TaoChenOSU TaoChenOSU changed the title Python: Refactor workflows kwargs [BREAKING] Python: Refactor workflows kwargs Apr 1, 2026
@TaoChenOSU TaoChenOSU enabled auto-merge April 1, 2026 21:25
@TaoChenOSU TaoChenOSU added this pull request to the merge queue Apr 2, 2026
Merged via the queue into microsoft:main with commit 62595b2 Apr 2, 2026
31 checks passed
@github-project-automation github-project-automation Bot moved this from In Review to Done in Agent Framework Apr 2, 2026
alliscode pushed a commit to alliscode/agent-framework that referenced this pull request Apr 3, 2026
* Refactor workflows kwargs usage

* Update sample

* Add tests

* Update samples

* Fix formatting

* Comments

* Comments 2

* Comments 3

* Fix test and typing
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python workflows Related to Workflows in agent-framework

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Python: remove workflow kwargs compatibility paths

5 participants