Repository navigation
Python: fix(core): allow switch-case branches to share a target executor - #9300
Merged
Eduard van Valkenburg (eavanvalkenburg) merged 1 commit intoOct 13, 2026
Conversation
Md. Shalah Uddin (shanto462)
temporarily deployed
to
github-app-auth
October 12, 2026 10:37 — with
GitHub Actions
Inactive
Md. Shalah Uddin (shanto462)
temporarily deployed
to
github-app-auth
October 12, 2026 10:38 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused implementation preserves case routing semantics and includes appropriate unit and workflow regression coverage.
0 open findings
What changed in this PR
Fixes switch-case workflows so multiple cases can safely share one target executor.
Changes:
- Deduplicates target edges while preserving first-seen order.
- Adds unit coverage for routing, ordering, and shared defaults.
- Adds an end-to-end workflow regression test.
| File | Description |
|---|---|
python/packages/core/agent_framework/_workflows/_edge.py |
Creates one edge per distinct switch target. |
python/packages/core/tests/workflow/test_edge.py |
Verifies deduplication and case selection. |
python/packages/core/tests/workflow/test_workflow.py |
Verifies shared-target workflows build and run. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
Md. Shalah Uddin (shanto462)
marked this pull request as ready for review
October 12, 2026 10:49
Md. Shalah Uddin (shanto462)
requested review from
SergeyMenshykh,
Tao Chen (TaoChenOSU),
Eduard van Valkenburg (eavanvalkenburg),
Giles Odigwe (giles17),
Jose Alvarez (jpalvarezl),
Evan Mattson (moonbox3),
Roger Barreto (rogerbarreto),
sophia-ramsey and
westey (westey-m)
as code owners
October 12, 2026 10:49
Md. Shalah Uddin (shanto462)
temporarily deployed
to
github-app-auth
October 12, 2026 11:00 — with
GitHub Actions
Inactive
Eduard van Valkenburg (eavanvalkenburg)
approved these changes
Oct 13, 2026
Md. Shalah Uddin (shanto462)
temporarily deployed
to
github-app-auth
October 13, 2026 11:08 — with
GitHub Actions
Inactive
Md. Shalah Uddin (shanto462)
deleted the
fix-switch-case-shared-target
branch
October 19, 2026 09:42
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation & Context
A switch-case edge group where two cases (or a case and the default) target the same executor failed at
build()withEdgeDuplicationError.SwitchCaseEdgeGroupcreated one edge per case, so a shared target produced the same edge twice. Routing several conditions to one handler is a common pattern, and the .NETSwitchBuilderallows it.Description & Review Guide
SwitchCaseEdgeGroupcreates one edge per distinct target, in the order the targets first appear. Thecaseslist is unchanged, so every case still routes to its own target. A unit test intest_edge.pychecks the edges, their order and the selection for each case. A workflow test builds and runs a switch where two cases share a target.add_edgebetween the same two executors is still rejected as a duplicate.casesstill lists every case, andedgeslists each target once.from_dictrebuilds the targets fromedges, so a round trip keeps the same targets and cases.Related Issue
Fixes #9297
No other open PR covers this issue.
AI Assistance
AI assistance details: issue analysis, implementation, tests, and this PR description.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.