We compute the average work done by an external agent, driving a piston at constant speed, over a single-particle gas going through an adiabatic compression and expansion process. To do so, we get the analytical expression relating the number of collisions between the piston and the particle with the position of the piston during the process. The ergodicity breaking of the system during the process is identified as the source of its irreversibility. In addition, we observe that by using particular initial distributions for the state of the particle, it is possible to preclude the possibility of a net energy transfer from the agent to the particle during the process.