
171 Cal.App.3d 620 (1985)
217 Cal. Rptr. 393
THE PEOPLE, Plaintiff and Respondent,
v.
MACEIO McNIGHT, Defendant and Appellant.
Docket No. A024095.
Court of Appeals of California, First District, Division Three.
August 26, 1985.
*622 COUNSEL
Bryan Kemnitzer, under appointment by the Court of Appeal, for Defendant and Appellant.
John K. Van de Kamp, Attorney General, and Robert R. Granucci, Deputy Attorney General, for Plaintiff and Respondent.
OPINION
BARRY-DEAL, J.
Maceio McNight appeals from the judgment entered after his plea of guilty.[1] Appellant contends that (1) this appeal is not subject to the requirement of a probable cause certificate pursuant to Penal Code section 1237.5;[2] (2) appellant was denied effective assistance of counsel at sentencing because his counsel failed to urge mitigating circumstances; and (3) the trial court erred in failing to consider mitigating circumstances before sentencing. We do not agree that appellant is exempt from the requirement of a certificate of probable cause, and we dismiss the appeal. As a result, we do not reach the issues concerning effective assistance of counsel and mitigating circumstances.[3]

Facts
In information No. 104986, filed in the superior court on April 27, 1981, appellant was charged in counts I through V, relating to the victim S., with assault with intent to commit rape (§ 220), two counts of rape (§ 261, subd. (3)), assault with force likely to produce great bodily injury (§ 245, subd. (a)), and false imprisonment (§ 236). He was charged in counts VI through XI, relating to the victim K., with kidnaping (§ 207), robbery (§ 211), two counts of rape (§ 261, subd. (2)), oral copulation (§ 288a), and assault with a deadly weapon (§ 245, subd. (a)). The information also alleged firearm use enhancements (§ 12022.3, subds. (a), (b)) in connection with the sex offenses against victim K. and firearm use enhancements under section 12022.5 in connection with the robbery and assault of victim K.
*623 In criminal complaint No. 406908, filed in the municipal court on April 22, 1981, appellant was charged in three counts, relating to a third victim, with rape (§ 261, subd. (3)), assault with force likely to produce great bodily injury (§ 245, subd. (a)), and false imprisonment (§ 236). He pled guilty to the rape count on condition that he receive the middle-term sentence and that the other two counts be dismissed. The cause was then certified to the superior court for sentencing under No. 105595.
Pursuant to the plea agreement with the district attorney in superior court, appellant pled guilty to three counts of rape (two from information No. 104986 and one from No. 105595) and one firearm use allegation (§ 12022.3, subd. (a)). The prosecution dismissed the remaining charges and agreed to recommend the middle term for each rape charge (six years), plus a three-year enhancement for firearm use.
The court found appellant to be a mentally disordered sex offender and committed him to Atascadero State Hospital for a period not to exceed 21 years, the length of the sentence recommended by the prosecution pursuant to the plea agreement. Appellant was returned to the court as not amenable to treatment. The court vacated the commitment order and sentenced appellant to 21 years in prison, with credit for the time he was committed to the hospital. Appellant filed a notice of appeal and applied for a certificate of probable cause pursuant to section 1237.5, which the court denied on the ground that no legal basis existed for his petition.

Discussion
(1a) Appellant contends that his appeal is properly before this court despite the trial court's denial of a certificate of probable cause pursuant to section 1237.5. That section provides, in pertinent part: "No appeal shall be taken by defendant from a judgment of conviction upon a plea of guilty ... except where: [¶] (a) The defendant has filed with the trial court a written statement, executed under oath or penalty of perjury showing reasonable constitutional, jurisdictional, or other grounds going to the legality of the proceedings; and [¶] (b) The trial court has executed and filed a certificate of probable cause for such appeal with the county clerk."
Two recognized exceptions to the section 1237.5 requirement are codified in California Rules of Court, rule 31(d): "... If the appeal from a judgment of conviction entered upon a plea of guilty ... is based solely upon grounds (1) occurring after entry of such plea which do not challenge the validity of the plea or (2) involving a search or seizure, ... the provisions of section 1237.5 of the Penal Code requiring a statement by the defendant and a certificate of probable cause by the trial court are inapplicable, ..."
*624 Appellant contends that his challenge to the sentence imposed in this case falls within the first exception because sentencing took place after his guilty plea, and he does not challenge the validity of the plea itself.
Although rule 31(d), California Rules of Court, refers to grounds occurring after the entry of a guilty plea, the timing of such grounds is not a conclusive factor. In determining the applicability of section 1237.5 to a challenge of a sentence imposed after a guilty plea, "... the crucial issue is what the defendant is challenging, not the time or manner in which the challenge is made." (People v. Ribero (1971) 4 Cal.3d 55, 63 [92 Cal. Rptr. 692, 480 P.2d 308].) Therefore, the threshold question here is whether appellant's challenge to the sentence imposed pursuant to a plea agreement is in substance a challenge to his guilty plea, and thus subject to the requirements of section 1237.5. The "substance-of-the-appeal" test requires us to determine if the facts support a challenge to the sentence imposed rather than to validity of the guilty plea, without determining the merits of the appeal itself. (Id., at pp. 62-64.)
Appellant claims that because he does not seek withdrawal of his guilty plea, but only appellate review of the sentencing procedure, section 1237.5 should not bar his appeal. His contention is without merit. "The state, in entering a plea bargain, generally contemplates a certain ultimate result; integral to its bargain is the defendant's vulnerability to a term of punishment.... When a defendant gains total relief from his vulnerability to sentence, the state is substantially deprived of the benefits for which it agreed to enter the bargain. Whether the defendant formally seeks to withdraw his guilty plea or not is immaterial; it is his escape from vulnerability to sentence that fundamentally alters the character of the bargain." (People v. Collins (1978) 21 Cal.3d 208, 215 [145 Cal. Rptr. 686, 577 P.2d 1026].) Appellant pled guilty with conditions including that the prosecutor recommend a sentence of 21 years. He does not contend that this plea agreement was breached in any respect. The gravamen of this appeal is that appellant was prejudiced by the trial court's acceptance of the prosecutor's recommendation and by his counsel's failure to argue mitigating circumstances.
The prosecutor was bound by the plea agreement, and any change in the agreement's terms would have given appellant the right to withdraw the guilty plea. (People v. Delles (1968) 69 Cal.2d 906, 910-911 [73 Cal. Rptr. 389, 447 P.2d 629].) In this case, unlike Delles, appellant received exactly the sentence promised in the agreement. His contention that consideration of mitigating circumstances should have resulted in imposition of a sentence less than the agreed-upon 21 years goes to the heart of the plea agreement itself.
*625 People v. Ward presents an enlightening contrast to the case at bench. There, the sentencing procedures were "altogether distinct" from the defendant's guilty plea because the defendant's plea was not predicated on either a finding of any specific degree of the crime charged or the penalty to be imposed. (People v. Ward (1967) 66 Cal.2d 571, 575 [58 Cal. Rptr. 313, 426 P.2d 881].) Ward was thus allowed to appeal his sentence unhampered by the requirements of section 1237.5. (Ward, supra, at p. 576.) Here, however, the sentencing hearing provided the setting for the performance of the plea agreement. The terms of the agreement were discussed, and the trial court acted in complete accordance with those terms. Thus, appellant's sentencing hearing was not separate and distinct from his plea of guilty.
This case is analogous to People v. Williams (1980) 103 Cal. App.3d 507 [163 Cal. Rptr. 169], in which the defendant pled guilty pursuant to a plea agreement and was sentenced to a base term plus a one-year enhancement based on a prior felony conviction. He sought appeal on the ground that his guilty plea did not include an admission of the prior conviction and that the one-year enhancement was therefore improper. (Id., at p. 511.) The court held that the defendant was in effect raising a defect in the guilty plea proceedings during which he had agreed to the sentence and that the challenge was not cognizable on appeal because defendant had not obtained a certificate of probable cause. (Id., at p. 512.) The same considerations are applicable in the instant case  appellant agreed to accept a 21-year sentence in exchange for his guilty plea.[4] (2) (See fn. 5.) Therefore, in light of the fact that appellant was denied a certificate of probable cause, we will not reach the merits of his appeal.[5]
(1b) Appellant alternatively relies on People v. Holland (1978) 23 Cal.3d 77 [151 Cal. Rptr. 625, 588 P.2d 765], in which the court held that a certificate of probable cause is not necessary to perfect an appeal from a guilty plea when the trial court has certified, by words or conduct, a record *626 on appeal "`... in circumstances where to have denied a certificate ... would have constituted an abuse of discretion,'..." (Id., at p. 85, quoting In re Brown (1973) 9 Cal.3d 679, 683, fn. 6 [108 Cal. Rptr. 801, 511 P.2d 1153].) Here, certification by the trial judge does not appear in any form in the record, so appellant is not relieved of the necessity of producing a certificate of probable cause.
The appeal is dismissed.
Scott, Acting P.J., and Anderson, J.,[*] concurred.
Appellant's petition for review by the Supreme Court was denied November 14, 1985.
NOTES
[1]  Respondent concedes the timeliness of this appeal. Appellant was committed to Atascadero State Hospital on August 10, 1981. While the court could have sentenced appellant on that date and suspended execution of the sentence during commitment, it did not formally sentence appellant until he was returned to court on August 15, 1983. Notice of appeal was timely filed on August 30, 1983. (See People v. Munoz (1975) 51 Cal. App.3d 559, 563 [124 Cal. Rptr. 322].)
[2]  All further statutory references are to the Penal Code.
[3]  These same issues were raised on a petition for habeas corpus relief and found to be without merit.
[4]  It is significant that appellant's plea agreement included a specific recommended sentence of three middle terms plus a three-year enhancement. If appellant had pled guilty on the sole condition that the other charges against him be dropped, the trial court could have selected any appropriate sentence without violating the plea agreement. In that situation, the sentencing proceedings probably would not be part of the plea itself, and section 1237.5 requirements might not apply. (See, e.g., People v. Pinon (1979) 96 Cal. App.3d 904, 910 [158 Cal. Rptr. 425] [trial court "selected" an upper term]; People v. Jones (1980) 111 Cal. App.3d 597, 604 [169 Cal. Rptr. 28] [sentence term not part of definitive agreement].)
[5]  We note that even if the appeal were properly before us, we would reject appellant's claim of inadequacy of counsel. The trial attorney's failure to argue mitigating circumstances at the sentencing hearing is explained simply by the fact that the length of sentence was established by the plea agreement. Reasonably competent attorneys are not required to make frivolous arguments. (See, generally, People v. Fosselman (1983) 33 Cal.3d 572, 581-584 [189 Cal. Rptr. 855, 659 P.2d 1144].)
[*]   Assigned by the Chairperson of the Judicial Council.
