adk-python icon indicating copy to clipboard operation
adk-python copied to clipboard

fix(workflow): exclude done tasks from get_dynamic_tasks

Open Goutham-Annem opened this issue 5 months ago • 1 comments

Link to Issue or Description of Change

Closes: #6082

After a ParallelWorker completes, its tasks remain in self.runs with task.done() == True. get_dynamic_tasks() returned all tasks indiscriminately, so _cleanup_all_tasks() saw a non-empty list and logged:

Workflow <name>: cancelling N leftover tasks.

on every clean workflow run — even when nothing actually needed cancellation.

The fix filters out done tasks so only still-running tasks are returned. Calling task.cancel() on a done task is already a no-op in Python, and task.cancelled() returns False for a normally-completed task, so existing cleanup logic is unaffected. The only observable change is suppression of the false warning.

Testing Plan

Unit Tests:

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

Added test_get_dynamic_tasks_excludes_done_tasks in test_dynamic_node_scheduler.py:

  • Places one done task, one running task, and one task=None run in the state
  • Asserts get_dynamic_tasks() returns only the running task

Manual End-to-End (E2E) Tests: Running a workflow with a ParallelWorker no longer emits the "cancelling N leftover tasks" warning in the logs after successful completion.

Goutham-Annem avatar Jun 15 '26 00:06 Goutham-Annem

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Jun 15 '26 00:06 google-cla[bot]

Merged in squashed commit thank you!

GWeale avatar Jun 16 '26 18:06 GWeale