Return an empty task list from `GraphRun.next_task` after a map over an empty list

Merged
AD
22d ago
+34-1

After a map over an empty list, the graph yields an empty task list, but GraphRun.next_task returned ['__start__'] for it mid-run. The property used self._next or [self._first_task], so an empty list read as "not started".

It now checks self._next is None, the same "not started" test __anext__ and next() already use. The same wrong answer showed for the empty step a map over an async iterable yields when it finishes, and for override_next([]); this one line covers all of them. The iterator yielding [] is deliberate (it is where a caller can override what runs next), so the property is the right place. The only other reader, AgentRun in run.py, never sees an empty list since the agent graph has no maps.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.

Summary by cubic

Fixes GraphRun.next_task returning the start task instead of an empty task list after a map over an empty list.

  • The property now checks self._next is None instead of its truthiness, matching the "not started" test used by __anext__ and next().
  • This also fixes the empty step yielded when a map over an async iterable finishes, and when override_next([]) is used.
  • Adds a test covering the empty-map iteration sequence.