Skip to content

Python: Fix workflow kwargs collision with __global__ executor IDs - #8311

Open
WhaleTech (ryo-whaletech) wants to merge 2 commits into
microsoft:mainfrom
ryo-whaletech:fix/8310-workflow-kwargs-global-collision
Open

WhaleTech (ryo-whaletech) wants to merge 2 commits into
microsoft:mainfrom
ryo-whaletech:fix/8310-workflow-kwargs-global-collision

Conversation

@ryo-whaletech

@ryo-whaletech WhaleTech (ryo-whaletech) commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Motivation & Context

Workflow invocation kwargs historically use __global__ both as a global namespace sentinel and as an executor-specific key. That shared key can allow executor-specific __global__ values to overwrite true globals; when a real executor has that ID, its targeted kwargs can also leak to sibling executors.

This fixes the namespace collision reported in #8310 while retaining the historical state representation for older consumers and checkpoints.

Description & Review Guide

  • What are the major changes?

    • Store collision-free resolved kwargs in separate global and executor-specific namespaces while retaining the historical state representation for compatibility.
    • Centralize executor-ready kwargs conversion in Core and reuse it from AgentExecutor, GroupChat, and updated Declarative workflows.
    • Preserve raw caller input for nested workflow classification and retain Declarative's historical forwarding path when resolved state is absent.
  • What is the impact of these changes?

    • Real __global__ executors receive their targeted kwargs plus true global kwargs without leaking values to siblings.
    • True global kwargs are no longer overwritten by executor-specific __global__ values.
    • Flat global mappings, ordinary per-executor mappings, legacy mixed mappings, and specific-over-global precedence remain compatible.
    • Older consumers and legacy checkpoints continue to receive the historical representation.
  • What do you want reviewers to focus on?

    • The separation between the compatibility state and the collision-free resolved state.
    • The fallback boundary for older Declarative/Core combinations.
    • Shared routing behavior across AgentExecutor, GroupChat, Declarative, nested workflows, and checkpoints.

Related Issue

Fixes #8310

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 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.

🟡 Changes recommended

Declarative workflow executors cannot consume the new non-mapping state object and will fail when forwarding invocation kwargs.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Introduces collision-free workflow kwargs routing while preserving legacy checkpoint compatibility.

Changes:

  • Separates global and executor-specific kwargs.
  • Updates nested workflow and agent resolution.
  • Adds routing and checkpoint regression tests.
File summaries
File Description
_const.py Defines structured resolved kwargs.
_workflow.py Normalizes invocation kwargs.
_workflow_executor.py Forwards kwargs to nested workflows.
_agent_executor.py Resolves kwargs for agents.
test_workflow_kwargs.py Adds routing and restoration coverage.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 1
  • Review effort level: Balanced

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

Comment thread python/packages/core/agent_framework/_workflows/_const.py Outdated

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.

🟡 Changes recommended

Plain mixed global and executor-specific mappings no longer preserve their established merge behavior.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Review details
  • Files reviewed: 7/7 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment thread python/packages/core/agent_framework/_workflows/_workflow.py Outdated
Comment thread python/packages/core/agent_framework/_workflows/_workflow.py Outdated
auto-merge was automatically disabled September 14, 2026 13:49

Head branch was pushed to by a user without write access

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]: Workflow invocation kwargs collide with an executor ID of __global__

3 participants