.NET: Python: [Bug]: Two switch-case branches cannot route to the same executor (EdgeDuplicationError)
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 78/100
Direzione di ricerca
Inizia in agent_framework/_workflows/_edge.py, in corrispondenza di SwitchCaseEdgeGroup.__init__, dove l’issue segnala edge duplicate per destinazioni ripetute. Leggi l’implementazione del gruppo di edge e la validazione delle edge del workflow, poi controlla i test di regressione per il routing switch-case. Il lavoro è completato quando più cases, oppure un case e il default, possono condividere una destinazione, il workflow viene costruito e il comportamento del routing rimane corretto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 14k
- Fork
- 2.5k
- Merge medio
- 2g 4h
- PR unite (30g)
- 403
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di microsoft/agent-framework
-
Python: [Bug]: Out-of-range Cosmos memory search parameters silently disable retrievalForse già presa @eavanvalkenburg l’ha presa 1 giorno fa. Apertapython
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
microsoft/agent-framework#9317 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Python: [Bug]: A non-positive MCP request timeout silently disables the timeoutForse già presa @jpalvarezl l’ha presa 1 giorno fa. Apertapython
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
microsoft/agent-framework#9313 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Python: [Bug]: Content.from_dict leaves the nested content of image generation and MCP server tool results as plain dictsForse già presa @eavanvalkenburg l’ha presa 1 giorno fa. Apertapython
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
microsoft/agent-framework#9303 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
.NET python triage
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
microsoft/agent-framework#9092 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Python: raw-data content mappings lose annotations and attachment metadataForse già presa @moonbox3 l’ha presa 14 giorni fa. Apertapython triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
microsoft/agent-framework#8632 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di microsoft/agent-framework
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
-
[Bug]: Importing weave changes the process-wide localeForse già presa @himanshu748 l’ha presa oggi. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
UX
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
mediajunkie/piper-morgan-product#2008 · 2 commenti ·