Skip to content

Python: Forward invocation kwargs during nested workflow cancellation - #8602

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 5 commits into
microsoft:mainfrom
ryo-whaletech:fix/candidate-028-python-bug-nested-workflow-cancellation-re
Oct 1, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 5 commits into
microsoft:mainfrom
ryo-whaletech:fix/candidate-028-python-bug-nested-workflow-cancellation-re

Conversation

@ryo-whaletech

@ryo-whaletech WhaleTech (ryo-whaletech) commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

Cancelling a propagated child request with replacement function-invocation or client kwargs must apply those active settings to the nested continuation. Previously, the wrapper forwarded only runtime tools and the child retained stale kwargs. Explicit replacements must also remain distinct from omitted channels when scoping removes every replacement key.

Description & Review Guide

  • What are the major changes? Reuse child-aware kwargs extraction for nested start and cancellation, and forward both kwargs channels during cancellation. Preserve supplied-but-empty values specifically for cancellation. Extend provider-free regressions for wrapper-only typed and legacy replacements, explicit empty values, both and single-channel replacements, omitted inputs, nested workflows, checkpoint restoration, and a downstream AgentExecutor.
  • What is the impact of these changes? Nested cancellation applies replacement kwargs and clears the stale omitted peer when one channel is supplied. Omitting both retains previous settings. Fresh-start scoping, public signatures, and serialized state formats are unchanged. Existing child validation still applies; no exception handlers are added or changed. Additional diagnostics identified a separate validation-failure case where parent and child pending states diverge. It reproduces before the empty-value correction and is planned for a separate issue; this PR does not introduce exception suppression or rollback behavior.
  • What do you want reviewers to focus on? Omitted versus supplied-but-empty cancellation kwargs, unchanged fresh-start behavior, and typed/legacy routing across nested graph boundaries.

Related Issue

Fixes #8601

Related: merged PR #8596 scopes invocation kwargs by executor graph. This change preserves those boundaries while addressing cancellation continuation. A pre-publication search found no other open PR addressing #8601.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and the title prefix in sync automatically.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

The stale omitted-channel clearing behavior needs targeted regression coverage.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Forwards request-scoped invocation kwargs into nested workflow cancellation.

Changes:

  • Extracts shared child-kwargs resolution logic.
  • Adds nested cancellation regression coverage.
File Description
_workflow_executor.py Forwards both kwargs channels during cancellation.
test_workflow_kwargs.py Tests replacement kwargs in child cancellation.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread python/packages/core/tests/workflow/test_workflow_kwargs.py Outdated
@eavanvalkenburg

Copy link
Copy Markdown
Member

WhaleTech (@ryo-whaletech) This branch currently conflicts with main. Please merge or rebase current main and resolve the conflicts before requesting another review.

@ryo-whaletech

WhaleTech (ryo-whaletech) commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Eduard van Valkenburg (@eavanvalkenburg) Thanks for the heads-up — I’ve updated the branch with current main and resolved the conflict. I’ve re-requested review.

Merged via the queue into microsoft:main with commit 387d5c7 Oct 1, 2026
45 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — 21026679 Deployed Sep 30, 2026 by ryo-whaletech via add_label #24125
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Usage: [Issues, PRs], Target: Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Nested workflow cancellation retains stale invocation kwargs

3 participants