No, it's not illegal, though admittedly it seems like it should be:1) The judge, not the prosecutor, determines sentencing; the judge usually follows prosecutor recommendations but is not required to and the prosecutor cannot "bind" the judge. This is always a risk in pleaing: while the judge cannot change the offense you pled to, he does not have to give any agreed-upon sentence.2) The judge must follow the law, such as sentences laid out in the criminal code; he cannot give less (or more) than the law allows given this offense and also any prior offenses that increase the sentence.