Accessibility turned back off - how to keep it on?
This probably is the battery saving mode (Android 7) as you suggest.

On my Samsung you can mark Automate (or any other app) as an app not to be checked for battery drain.


From Settings, select Device maintenance.   
Select Battery at    the bottom left of the screen.   
At the bottom    of the next screen is    a list of apps that are
currently considered    by Android as using    power.  Automate is
probably on that list.  
Below the list is a button "Unmonitored Apps", select this.
Select Add apps and add Automate to those apps that are no longer
checked and put to sleep by the OS.


The exact method may be slightly different on your phone but the principle should be the same.