Very true.
You can have a plea agreement in place, good relationship with the prosecutor but it all comes down to the judge at the end of the day. The judge brings his or her own biases to the bench and thus rulings.
I had run in's with three letter agencies almost a decade ago for a financial matter. Forced to plea, etc. My attorneys, some of the best there were/are at the time, were ecstatic that I got a particular judge for my sentencing. The other judge I could have got, let's call him Judge M, had a nickname in the district: "The Time Machine". He was the most harsh and cruel judge in the whole damn state apparently and handed down so many fucking years all the time, he earned the nickname The Time Machine. Nasty old white judge in his late 60's who I swear to christ after researching him literally took pleasure in locking people up as long as humanly possible. Nasty, nasty person....
A nice plea agreement with a bow tie on top, simple probation for X many months, minimal supervision, etc is not, I repeat, is not a sure thing when it comes down to sentencing.