Isn't DAnconia55 right that the judge would also have to agree to keep the matter sealed?
I don't know New York law, but I do know the judge in my state would have to approve of the agreement. However, in Wisconsin, these are called "deferred prosecution agreements" and the judge holds the hearings to approve the DPAs in open court. Once the terms of the DPA are met--usually staying out of trouble for a certain number of months (usually 6 to 24 months), the charges are dismissed and the case goes away. If the person under the DPA gets busted during that time period, the person gets prosecuted on the original charges PLUS the new ones. It's like probation, except this is pre-conviction and there's no visit to a PO. The person is just trusted to be good for that length of time.
It could be the judge's tush is going to be on the line as well. But if only Ritter's lawyer appeared for William S. Ritter (Scott is his middle name) and the prosecutor and defense attorney were in agreement, all the judge would've done is rubber stamp it. He or she may not have known that this was Scott Ritter, talking head.
I do wonder, though, why the ADA would risk her job--and probably her career and law license (if not disbarment, at least a bar ethics investigation and a possible suspension of her law license)--for Scott Ritter. And I wonder where she's working now.