Bond lengthening occurs when creating a vacuum layer

Dear users, the first picture is the model after pressing my npt ensemble. There are broken bonds on the surface due to periodicity. On this basis, a vacuum layer is directly established, and the bond is stretched as shown in the figure. How to solve this?