Skip to content

fix(cli): render empty workflow agents without IndexError - #8349

Open
feiiiiii5 wants to merge 1 commit into
google:mainfrom
feiiiiii5:feiiiiii5/D265
Open

feiiiiii5 wants to merge 1 commit into
google:mainfrom
feiiiiii5:feiiiiii5/D265

Conversation

@feiiiiii5

Copy link
Copy Markdown
Contributor

Please ensure you have read the contribution guide before creating this pull request.

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

2. Or, if no issue exists, describe the change:

Problem: The Dev UI agent graph crashed with IndexError: list index out of range for a valid agent tree containing an empty SequentialAgent / LoopAgent. build_cluster() indexes sub_agents[0] for the parent edge even though the runtime explicitly allows an empty workflow shell (sequential_agent.py:99-100) and sub_agents defaults to [].

Solution: Guard the parent→first-sub-agent edge with if parent_agent and agent.sub_agents: in both branches. An empty workflow now draws its labelled cluster with no child edges. Non-empty rendering is byte-identical to base (verified 6/6 DOT sources). Per CONTRIBUTING, new bugs may be described in a PR using the issue template.

Testing Plan

Unit Tests:

  • I have added or updated unit tests for my change.
  • All unit tests pass locally.

New parametrized tests cover empty Sequential/Loop as root and as a child (4 cases). Base-red: 2 failed / 12 passed with IndexError; with fix 14/14 passed. ruff check and isort --check-only clean on both files.

Manual End-to-End (E2E) Tests:

Not run offline: no real model, network, or credentials available. The graph is pure logic; DOT source is asserted in unit tests without the dot binary.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end (offline environment; see above).
  • Any dependent changes have been merged and published in downstream modules.

Additional context

The repo uses pyink (unavailable offline), so ruff format was not used; new code matches surrounding style. Broader CLI tests could not be collected offline due to pre-existing missing-dependency errors unrelated to this change.

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.

1 participant