envoyd: better agent environment handling