Skip to content

fix(adk): swarm team vacío lanza ValueError descriptivo en vez de IndexError - #11

Open
01luyicheng wants to merge 1 commit into
monaccode:developfrom
01luyicheng:fix/adk-swarm-empty-team-indexerror
Open

fix(adk): swarm team vacío lanza ValueError descriptivo en vez de IndexError#11
01luyicheng wants to merge 1 commit into
monaccode:developfrom
01luyicheng:fix/adk-swarm-empty-team-indexerror

Conversation

@01luyicheng

Copy link
Copy Markdown

Motivo

Closes #3.

Cuando un AgentTeam con patrón swarm se construye sin entry_agent ni agents, ADKRuntime._run_swarm hacía entry = team.entry_agent or team.agents[0] y estallaba con IndexError: list index out of range — un error opaco que no dice nada sobre la configuración incorrecta del team.

Cambios

  • astromesh_adk/runner.py: _run_swarm valida al inicio que el team tenga entry_agent o agents; si no, lanza ValueError("swarm team '<name>' has no entry_agent and no agents").
  • tests/test_runner_local.py: agrega dos tests — test_run_team_swarm_returns_entry_answer (camino feliz, que además cubre el patrón swarm que hoy no tenía tests de run_team) y test_run_team_swarm_empty_team_raises_valueerror (el caso del issue).
  • CHANGELOG.md: entrada bajo [Unreleased] → Fixed.

Cómo probar

uv run pytest astromesh-adk/tests/test_runner_local.py -v
uv run pytest astromesh-adk/tests -q

Resultado local: 18 passed en test_runner_local.py. La suite completa de astromesh-adk tiene 1 fallo preexistente en test_public_api.py::test_version (espera 0.1.9 pero el paquete ya está en 0.2.0), no introducido por este PR y fuera de su alcance. El job test de CI raíz no ejecuta astromesh-adk/tests/ (testpaths=["tests"], sin job test-adk), así que este fallo preexistente no pone CI en rojo.

Notas / fuera de alcance

  • Revisé los demás patrones (parallel, pipeline, supervisor): ninguno indexa team.agents[0], así que el guard solo hace falta en _run_swarm — el "Consider the same guard" del issue queda cubierto por esa revisión.
  • El patrón supervisor sí tiene un problema análogo de configuración incompleta (team.supervisor is NoneAttributeError en supervisor.name), pero es otro tipo de excepción y otro modo de configuración; queda fuera del alcance de este issue. Lo dejo anotado por si les sirve decidir abrir otro issue para ello.

…exError

`_run_swarm` hacía `entry = team.entry_agent or team.agents[0]` sin
guardar: si el team no tenía `entry_agent` ni `agents`, estallaba con
`IndexError: list index out of range`, sin decir nada sobre la
configuración incorrecta. Ahora lanza `ValueError` con el nombre del
team, y el patrón swarm queda cubierto por tests de `run_team` (que
hoy no tenía ninguno).

Closes monaccode#3.
Copilot AI review requested due to automatic review settings July 27, 2026 18:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants