(#13640) Only agents should use next_agent_run
The new event_loop code in daemon was adjusting the run time based on
next_agent_run even when not running an agent. This caused the interval to
always be 0 and peg CPU usage at 100%. We should only make this adjustment if
there is an agent running. This also somewhat refactors the logic around
next_event to avoid duplication.