The present invention is related to an agricultural baler for producing rectangular bales (7) provided with a baling chamber (1) and reciprocating plunger (4) configured to move back and forth in the baling chamber (1) thereby compressing crop material and forming rectangular bales (7). The baler is further equipped with a bale length control system (10) for producing bales of substantially equal length and with a bale eject system (20 24) for evacuating the last bales from the chamber (1) at the end of a harvesting run. In order to avoid errors in terms of bale length at the beginning of a next run the baler according to the invention is provided with one or more sensors (30) configured to detect the activation of said bale eject system (20 24) and means to automatically reset said bale length control system (10) when said sensors (30) detect said activation.