Revert "refactor implementation of runAGDag"

This reverts commit f338ca258ece0c0a15034b6be88c5aa75b9984a4.