In a manner similar to ConnectWise Control (ScreenConnect), make the ephemeral agent acquire a “wake lock” on the machine so that it does not go to sleep or hibernate during a session.
Alternatively I used to run a task that would get all the current power settings and hibernation state, save that config.
For something like a maintenance session, on detection the settings could be saved, then hibernation turned off and power settings set to always on.
Then once the maintenance session was finished, it could revert back to the settings it was before maintenance began.
That only works so long as the session doesn’t hang or get cancelled. I prefer the “wake lock” approach so that when the ephemeral agent becomes “inactive,” then the machine will resume its behavior as opposed to having to hard modify the power settings at the beginning and end of every session (plus, that won’t help if you ad-hoc deploy something large, like Autocad).