Section 18. A defendant who is before the Boston municipal court or a district court or a district court sitting in a juvenile session or a juvenile court on a criminal offense within the court’s final jurisdiction shall plead not guilty or guilty, or with the consent of the court, nolo contendere. Such plea of guilty shall be submitted by the defendant and acted upon by the court; provided, however, that a defendant with whom the commonwealth cannot reach agreement for a recommended disposition shall be allowed to tender a plea of guilty together with a request for a specific disposition. Such request may include any disposition or dispositional terms within the court’s jurisdiction, including, unless otherwise prohibited by law, a dispositional request that a guilty finding not be entered, but rather the case be continued without a finding to a specific date thereupon to be dismissed, such continuance conditioned upon compliance with specific terms and conditions or that the defendant be placed on probation pursuant to the provisions of section eighty-seven of chapter two hundred and seventy-six. If such a plea, with an agreed upon recommendation or with a dispositional request by the defendant, is tendered, the court shall inform the defendant that it will not impose a disposition that exceeds the terms of the agreed upon recommendation or the dispositional request by the defendant, whichever is applicable, without giving the defendant the right to withdraw the plea.
If a defendant, notwithstanding the requirements set forth hereinbefore, attempts to enter a plea or statement consisting of an admission of facts sufficient for finding of guilt, or some similar statement, such admission shall be deemed a tender of a plea of guilty for purposes of the procedures set forth in this section.
Any pretrial motion filed in a criminal case pending in the Boston municipal court or district court or a district court sitting in a juvenile session or a juvenile court and decided before entry of defendant’s decision on waiver of the right to jury trial shall not be refiled or reheard thereafter, except in the discretion of the court as substantial justice requires. Any such pretrial motion not filed or filed but not decided prior to entry of the defendant’s decision on waiver of the right to jury trial may be filed thereafter but not later than twenty-one days after entry of said decision on waiver of the right to jury trial, except for good cause shown.