I applied a geometry filter in the query to a ArcGIS Server Map Service (query enabled), when the ResultOffset is set to 0 and resultRecordCount is set to 500, it only returns 36 records

If I remove these parameters in the query, it returns all the features intersects with the geometry:

This only happens to the ArcGIS Server Service, if the service is hosted in the ArcGIS Enterprise Portal, it works OK.
Any idea what's happening?
Thanks you in advance.
please note that I posted the same question in the ArcGIS REST API Community a couple of days ago, but I am thinking it might also be a ArcGIS Server topic, as this happens on a ArcGIS Server Map/ Feature Service, but it works fine for a hosted service (I know the service is hosted on a federated server...), I am wondering it might have something to do with my ArcGIS Server settings. if it is true.