We investigate baryon effects on the halo mass function ( HMF ) , with emphasis on the role played by AGN feedback . Halos are identified with both Friends-of-Friends ( FoF ) and Spherical Overdensity ( SO ) algorithms . We embed the standard SO algorithm into a memory-controlled frame program and present the P ython spher I c A l O verdensity code — PIAO ( Chinese character : 漂 ) . For both FoF and SO halos , the effect of AGN feedback is that of suppressing the HMFs to a level even below that of Dark Matter simulations . The ratio between the HMFs in the AGN and in the DM simulations is \sim 0.8 at overdensity \Delta _ { c } = 500 , a difference that increases at higher overdensity \Delta _ { c } = 2500 , with no significant redshift and mass dependence . A decrease of the halo masses ratio with respect to the DM case induces the decrease of the HMF in the AGN simulation . The shallower inner density profiles of halos in the AGN simulation witnesses that mass reduction is induced by the sudden displacement of gas induced by thermal AGN feedback . We provide fitting functions to describe halo mass variations at different overdensities , which can recover the HMFs with a residual random scatter \lower 2.15 pt \hbox { $ \buildrel < \over { \sim } $ } 5 per cent for halo masses larger than 10 ^ { 13 } ~ { } h ^ { -1 } \ > { M _ { \odot } } .