.NET: Python: [Bug]: Two switch-case branches cannot route to the same executor (EdgeDuplicationError)
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
agent_framework/_workflows/_edge.py の SwitchCaseEdgeGroup.__init__ から始めてください。issue では、同じターゲットが繰り返される場合に edge が重複すると指摘されています。edge グループの実装と workflow の edge 検証を読み、その後、switch-case ルーティングの回帰テストを確認してください。複数の case、または case と default が同じターゲットを共有でき、workflow が構築され、ルーティングの動作が正しいままであれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Observed Behavior
WorkflowBuilder.add_switch_case_edge_group fails at build() with EdgeDuplicationError when two Case entries target the same executor. This is a common shape: several conditions lead to one handler, for example "refund" and "return" requests both go to a refunds executor. A Case and the Default that share a target fail the same way.
The only workaround is to merge the conditions into one Case.
Expected Behavior
The workflow builds, and each message is routed by the first matching case as usual. The .NET SwitchBuilder allows several cases with the same target.
Steps to Reproduce
- Add a switch-case edge group where two
Caseentries have the sametarget. - Call
build().
Minimal Reproduction
from agent_framework import Case, Default, Executor, WorkflowBuilder, WorkflowContext, handler
class Router(Executor):
@handler
async def route(self, message: str, ctx: WorkflowContext[str]) -> None:
await ctx.send_message(message)
class Handler(Executor):
@handler
async def handle(self, message: str, ctx: WorkflowContext[str, str]) -> None:
await ctx.yield_output(f"{self.id}: {message}")
router = Router(id="router")
refunds = Handler(id="refunds")
general = Handler(id="general")
workflow = (
WorkflowBuilder(start_executor=router)
.add_switch_case_edge_group(
router,
[
Case(condition=lambda m: m.startswith("refund"), target=refunds),
Case(condition=lambda m: m.startswith("return"), target=refunds),
Default(target=general),
],
)
.build() # raises EdgeDuplicationError
)
The cause is in agent_framework/_workflows/_edge.py: SwitchCaseEdgeGroup.__init__ creates one Edge per case, so two cases with the same target create the edge router->refunds twice, and workflow validation rejects duplicate edges. Routing only needs one edge per target, because the case conditions decide which target gets the message.
Error Messages and Stack Traces
File ".../agent_framework/_workflows/_validation.py", line 195, in _validate_edge_duplication
raise EdgeDuplicationError(edge_id)
agent_framework._workflows._validation.EdgeDuplicationError: [EDGE_DUPLICATION] Duplicate edge detected: router->refunds. Each edge in the workflow must be unique.
Package Versions
agent-framework-core: 1.21.0 (main at a75e803ef)
Python Version
Python 3.12
Additional Context
I'd like to fix this. The change is one line in SwitchCaseEdgeGroup.__init__ (one edge per distinct target, in order of first appearance) plus regression tests.
AI assistance: I used an AI coding assistant for the analysis and to draft this report. I reproduced and verified the behavior myself.
- 主要言語
- Python
- スター
- 14k
- フォーク
- 2.5k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 403
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/agent-framework のほかの issue
-
Python: [Bug]: Out-of-range Cosmos memory search parameters silently disable retrieval対応中かも @eavanvalkenburg が 1 日前に担当しました。 オープンpython
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/agent-framework#9317 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Python: [Bug]: A non-positive MCP request timeout silently disables the timeout対応中かも @jpalvarezl が 1 日前に担当しました。 オープンpython
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
microsoft/agent-framework#9313 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
Python: [Bug]: Content.from_dict leaves the nested content of image generation and MCP server tool results as plain dicts対応中かも @eavanvalkenburg が 1 日前に担当しました。 オープンpython
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
microsoft/agent-framework#9303 · 担当者 1 名 ·
メンテナーはふだん 1 日以内に返信
-
.NET python triage
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
microsoft/agent-framework#9092 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Python: raw-data content mappings lose annotations and attachment metadata対応中かも @moonbox3 が 14 日前に担当しました。 オープンpython triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
microsoft/agent-framework#8632 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
microsoft/agent-framework の issue をすべて見る
似ている issue
-
Agentic
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Imbad0202/academic-research-skills#979 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
reflex-dev/reflex#7561 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
prometheus-community/ansible#906 · コメント 2 件 ·