.NET: Python: [Bug]: Two switch-case branches cannot route to the same executor (EdgeDuplicationError)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 78/100
Hướng nghiên cứu
Bắt đầu tại agent_framework/_workflows/_edge.py, ở SwitchCaseEdgeGroup.__init__, nơi issue xác định các edge bị trùng khi có nhiều trường hợp cùng đích. Đọc phần triển khai nhóm edge và xác thực edge của workflow, sau đó kiểm tra các bài kiểm thử hồi quy cho định tuyến switch-case. Hoàn tất khi nhiều case, hoặc một case và default, có thể dùng chung một đích, workflow được xây dựng và hành vi định tuyến vẫn chính xác.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 14k
- Fork
- 2.5k
- Merge trung bình
- 2 ngày 9 giờ
- Pull request đã merge (30 ngày)
- 434
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của microsoft/agent-framework
-
Python: [Bug]: A non-positive MCP request timeout silently disables the timeoutCó thể đã có người làm @jpalvarezl đã nhận 3 ngày trước. Đang mởpython
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
microsoft/agent-framework#9313 · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
.NET: Proposal: add an llms.txtĐang mở.NET python triage
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
microsoft/agent-framework#9092 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Python: raw-data content mappings lose annotations and attachment metadataCó thể đã có người làm @moonbox3 đã nhận 17 ngày trước. Đang mởpython triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
microsoft/agent-framework#8632 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Python: Clarify when to use platformCó thể đã có người làm @eavanvalkenburg đã nhận 16 ngày trước. Đang mởpython triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
microsoft/agent-framework#8599 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
.NET compaction documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100
microsoft/agent-framework#4629 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của microsoft/agent-framework
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
omegaup/omegaup#10353 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 5 ngày
-
bot-triaged module: LrScheduler module: optimizer triaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation glm5 llm-model
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
vllm-project/vllm-ascend#19062 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Author Page: shuai-zhao-llmĐang mởauthor-page correction
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
acl-org/acl-anthology#10496 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày