KeepAlive with NetworkState not working for agent
Check the manpage (man launchd.plist) to see if NetworkState is implemented.

For me, on macOS Mojave, it is not:

KeepAlive &lt;boolean or dictionary of stuff&gt;

This optional key is used to control whether your job is to be kept continuously running
or to let demand and conditions control the invocation. The default is false and therefore
only demand will start the job. The value may be set to true to unconditionally keep the
job alive. Alternatively, a dictionary of conditions may be specified to selectively control
whether launchd keeps a job alive or not. If multiple keys are provided, launchd ORs them,
thus providing maximum flexibility to the job to refine the logic and stall if necessary.
If launchd finds no reason to restart the job, it falls back on demand based invocation.
Jobs that exit quickly and frequently when configured to be kept alive will be throttled
to conserve system resources.

    NetworkState &lt;boolean&gt;
    This key is no longer implemented as it never acted how most users expected.