If a plea agreement has been reached by the parties, the court shall, on the record, require the disclosure of the agreement in open court, or on a showing of good cause, in chambers, at the time the plea is offered. The prosecuting attorney shall disclose on the record any comments on the plea agreement made by the victim, or his designee, of the defendant's crime to the prosecuting attorney. Thereupon the court may accept or reject the agreement, or may defer its decision as to the acceptance or rejection until there has been an opportunity to consider the presentence report. If the court accepts a plea agreement involving any felony charge, the prosecuting attorney shall file a brief written report, which includes the terms of the plea agreement and the ultimate reasons therefor, with the division of criminal investigation and, if the defendant is incarcerated in a state correctional facility, also with the warden thereof.
SDCL 23A-7-9