A defendant shall not be sentenced for a felony before a written presentence report of investigation is presented to and considered by the court.
However, other than for felony sex offenders being considered for probation , the court need not order a presentence report of investigation where both parties agree to the imposition of a specific sentence, provided there is a finding made for the record as to the defendant's history of delinquency or criminality, including any previous sentence to a term of probation, periodic imprisonment, conditional discharge, or imprisonment.
The court may order a presentence investigation of any defendant.
730 ILCS 5/5-3-1