Skip to content

Python: fix(core): accept a bare container type as an edge target for a parameterized output - #8731

Merged
Eduard van Valkenburg (eavanvalkenburg) merged 5 commits into
microsoft:mainfrom
anishmehta24:fix/workflow-bare-container-target
Oct 9, 2026
Merged

Eduard van Valkenburg (eavanvalkenburg) merged 5 commits into
microsoft:mainfrom
anishmehta24:fix/workflow-bare-container-target

Conversation

@anishmehta24

Copy link
Copy Markdown
Contributor

Motivation & Context

A handler that takes a plain list (or dict, tuple, Sequence) can't receive a parameterized output from an upstream executor. The workflow fails to build:

class A(Executor):
    @handler
    async def go(self, x: str, ctx: WorkflowContext[list[str]]): ...

class B(Executor):
    @handler
    async def take(self, items: list, ctx: WorkflowContext[None, list]): ...

WorkflowBuilder(start_executor=a).add_edge(a, b).build()
# TypeCompatibilityError: ... outputs ['list[str]'] but target ... can only handle [<class 'list'>]

is_type_compatible compares get_origin(list[str]) (list) with get_origin(list) (None) in Case 5 and returns False before the "one side is untyped, assume compatible" rule in Case 6 is reached. The runtime check already accepts the message. The reverse, list -> list[str], fails the same way.

Description & Review Guide

  • What are the major changes? When one side is a bare container class, compare it with the other side's container with issubclass. list[str] -> list, dict[str, int] -> dict, list[int] -> Sequence and list -> list[str] are now compatible; list[str] -> dict still isn't.
  • What is the impact of these changes? Workflows with an unparameterized container input build instead of raising.
  • What do you want reviewers to focus on? list[Message] -> Sequence[Message] (both parameterized, different containers) is still rejected by Case 5. I left that out to keep this small.

Related Issue

No existing issue.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible

Tests: a unit case in test_typing_utils.py and a workflow build in test_validation.py; both fail on main. pytest packages/core/tests/workflow passes, and ruff and the repo's pre-commit checks are clean.

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 was unable to review this pull request because the user who requested the review has reached their quota limit.

@agent-framework-automation agent-framework-automation Bot added the python Usage: [Issues, PRs], Target: Python label Sep 24, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@anishmehta24

Copy link
Copy Markdown
Contributor Author

Eduard van Valkenburg (@eavanvalkenburg) also fixed the mypy error in the test, ready for another look.

Merged via the queue into microsoft:main with commit d53cdff Oct 9, 2026
45 checks passed

This branch was previously deployed

1 inactive deployment
github-app-auth — 326cafba Deployed Oct 6, 2026 by anishmehta24 via add_label #24572
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.

3 participants