.NET: Python: [Bug]: Two switch-case branches cannot route to the same executor (EdgeDuplicationError)
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 78/100
Línea de trabajo
Empieza en agent_framework/_workflows/_edge.py, en SwitchCaseEdgeGroup.__init__, donde el issue señala edges duplicadas para destinos repetidos. Lee la implementación del grupo de edges y la validación de edges del workflow; después, revisa las pruebas de regresión del enrutamiento switch-case. El trabajo estará terminado cuando varios cases, o un case y el default, puedan compartir un destino, el workflow se construya y el comportamiento del enrutamiento siga siendo correcto.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 14k
- Forks
- 2.5k
- Merge medio
- 2 d 4 h
- PR fusionados (30 d)
- 403
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/agent-framework
-
Python: [Bug]: Out-of-range Cosmos memory search parameters silently disable retrievalPosiblemente ocupada @eavanvalkenburg la tomó hace 1 día. Abiertopython
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/agent-framework#9317 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Python: [Bug]: A non-positive MCP request timeout silently disables the timeoutPosiblemente ocupada @jpalvarezl la tomó hace 1 día. Abiertopython
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
microsoft/agent-framework#9313 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
Python: [Bug]: Content.from_dict leaves the nested content of image generation and MCP server tool results as plain dictsPosiblemente ocupada @eavanvalkenburg la tomó hace 1 día. Abiertopython
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
microsoft/agent-framework#9303 · 1 asignado ·
Los mantenedores suelen responder en 1 día
-
.NET: Proposal: add an llms.txtAbierto.NET python triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
microsoft/agent-framework#9092 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Python: raw-data content mappings lose annotations and attachment metadataPosiblemente ocupada @moonbox3 la tomó hace 14 días. Abiertopython triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
microsoft/agent-framework#8632 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
Todos los issues de microsoft/agent-framework
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Deltares/imod-python#1940 ·
Los mantenedores suelen responder en 1 día
-
effort: low prio: low ready
Dificultad 1/5 Menos de una hora Aptitud para principiantes 82/100
digitalfabrik/integreat-cms#4621 ·
Los mantenedores suelen responder en 5 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
ioos/compliance-checker#1375 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
netbox status: backlog topic: testing type: housekeeping
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
netbox-community/netbox#23395 ·
Los mantenedores suelen responder en 1 día