
150 Cal.App.3d 910 (1984)
198 Cal. Rptr. 124
THE PEOPLE, Plaintiff and Respondent,
v.
JAMES SCOTT, Defendant and Appellant.
Docket No. AO17079.
Court of Appeals of California, First District, Division Three.
January 13, 1984.
*911 COUNSEL
Philip H. Pennypacker, under appointment by the Court of Appeal, Michael T. Chargin and Chargin & Chargin for Defendant and Appellant.
John K. Van de Kamp, Attorney General, Ann K. Jensen and Frances Marie Dogan, Deputy Attorneys General, for Plaintiff and Respondent.
*912 OPINION
WHITE, P.J. 
Background:
On March 3, 1981, appellant was charged with robbery (count 1); car theft (count 2); and burglary (count 3). On April 6, 1981, he was charged by information at an arraignment hearing in superior court.
On June 15, 1981, after a jury trial, he was found guilty on count 2. The jury could not reach a verdict on counts 1 and 3.
On June 22, 1981, there was a disposition hearing in superior court. Appellant announced he would enter a plea of guilty to count 1, on condition that he would receive a maximum of three years in state prison for the robbery and the car theft, counts 1 and 2. The court inquired whether there were factors in appellant's background which would make a referral to the California Rehabilitation Center (CRC) appropriate. When appellant's counsel said there were such factors, the court told appellant that he would be referred to the adult probation department for a presentence report.
The following dialogue then took place:
"The Court: ... If I find after the narcotic addiction proceedings have been concluded that you are an addict or about to become one, under the terms of this plea that is entered here today, you could be sentenced or committed to the California Rehabilitation Facility for up to three years, and then following that, you would be subject to a period of three years parole from that facility, at which time, or during which time you would be subject to narcotic testing. Is that clear? Do you understand that?
"The Defendant: Yes, sir.
"The Court: If you were to fail or refuse to comply with the narcotic addiction program while you are at CRC, or even while you are on parole, and you are referred back to the court for purposes of starting the criminal proceedings all over again, then in that event you must understand, and you must be willing to waive your rights in this regard, that the court then would have the option to place you in the state prison for a period of up to five years on the robbery, and to run that consecutively to the auto theft, for an additional eight months, for a total of five years and eight months. Do you understand that?
"The Defendant: Yes.
*913 "The Court: All right. Now, do you give up, at this time, your right at any subsequent hearing on the reinstitution of criminal proceedings, after you have been found a failure at CRC, to institute [sic] more than the maximum period of time of three years in the state prison?
"The Defendant: Yes, sir.
"The Court: By doing so, you must understand the court then would have the option to send you to state prison for five years and eight months. Is that correct?
"The Defendant: Yes, sir.
"The Court: And you are willing to accept that as part of the plea, is that right?
"The Defendant: Yes."
Appellant then pled guilty to count 1, and the district attorney moved to dismiss count 3, asking that the motion be taken under submission until sentencing.
On July 31, 1981, appellant was sentenced, on the basis of his guilty plea. At that hearing the court said, "On Count 1, violation of Penal Code section 211, the defendant is sentenced to state prison for the term of three years. This shall be the principal term." In addition, the court said "I ... will order that the defendant be sentenced to state prison [on Count 2] for the term of two years, and that term shall run concurrently with the principal term. [¶] The defendant is advised that he is subject to a period of three years under parole supervision, in the event that he is sent to state prison. [¶] I will ... advise the defendant ... that if he is committed to the California Rehabilitation Center, and he fails to cooperate in that program, then the court will have the option to impose a state prison sentence of five years and eight months. [¶] You recall that was the conditions [sic] under which the plea was entered? Appellant answered affirmatively. The court then said it would appoint a doctor pursuant to Welfare and Institutions Code section 3051.
At a further hearing on August 21, 1981, the court announced that "[t]he defendant has been previously sentenced, and the proceedings then were suspended until the report received by the doctor." The court found that appellant was in imminent danger of addiction to a variety of drugs including heroin, based on the doctor's report, and committed him to CRC. When the district attorney reminded the court that it was necessary to impose a *914 sentence before making a CRC referral, the court replied, "I did that. That has already been done. I did that at the last hearing on the matter."
Appellant next appeared in court April 2, 1982, because CRC had returned him pursuant to Welfare and Institutions Code section 3053. The purpose of this hearing, in the court's view, was to sentence appellant pursuant to the plea bargain, which had included the condition that if appellant failed to cooperate at CRC, he would be sentenced to five years and eight months in state prison. Defense counsel orally argued and filed contentions against this sentence, which were: (1) that appellant had already been sentenced, and that the court had no authority to increase the sentence; (2) that at the earlier sentencing hearing there were no findings of fact to support aggravating factors with regard to the principal term, and therefore the court could not impose an aggravated sentence for the principal term; (3) that commitment to CRC was involuntary and cooperation with the program could not be made a condition of a plea bargain; and (4) that Welfare and Institutions Code section 3053[1] required that appellant be sentenced to the term imposed prior to his referral to CRC. The district attorney's response was essentially that the fact of the very clear plea bargain, and appellant's unequivocal agreement to the three-year sentence being conditioned on his cooperating at CRC, gave the court jurisdiction to impose the longer sentence.
The superintendent of CRC had informed the court by letter that appellant had been received at the center August 27, 1981, and that he "should have been reviewed shortly thereafter for exclusion because of his commitment of the offense of robbery." By the time his case was reviewed on November 30, 1981, he had been transferred to "another institution" because he had been involved in a riot on November 13, 1981, during which he had threatened staff members with a table leg. The staff considered appellant an "instigator and agitator," and he had pled guilty at a disciplinary hearing to charges of threatening a staff member and inciting a disturbance.
After reading the CRC letter into the record, the court observed, "Clearly then, Mr. Scott has failed and refused to accept the offer that was made to [sic] the court.... I am at this time ready to proceed with the imposition of sentence." The court then sentenced appellant to five years on count 1 as the principal term, and two years on count 2, to run concurrently with the principal term.
*915 Appellant filed a notice of appeal on April 7, 1982, pursuant to rule 31(d) of the California Rules of Court, stating that the appeal is based solely on grounds occurring after the entry of the plea, and not challenging the validity of the plea itself.

Discussion:
(1a) Appellant contends that the trial court exceeded its jurisdiction by imposing a second sentence when sentence had already been pronounced but its execution suspended and by imposing a sentencing condition based on appellant's cooperation with an involuntary commitment to CRC, and that the trial court's discretion to approve a plea bargain did not include the right to impose a new condition. We conclude that the court acted in excess of its jurisdiction in attempting to impose a second sentence, and that the resolution of this issue precludes the others.

1. Penal Code section 1237.5 does not preclude raising these issues on appeal.

(2) Respondent raises the preliminary question of whether appellant's contentions are cognizable on appeal without a certificate of probable cause to appeal obtained from the trial court.
Penal Code section 1237.5 provides that, before filing an appeal following a plea of guilty, appellant must have filed a statement with the trial court showing "reasonable constitutional, jurisdictional, or other grounds going to the legality of the proceedings," and the trial court must have filed a certificate of probable cause for the appeal.
The Supreme Court has said, however, that this section "does not apply where a defendant does not challenge the original validity of the plea but asserts that errors were committed in proceedings subsequent to the plea for the purpose of determining the penalty to be imposed." (People v. Kaanehe (1977) 19 Cal.3d 1, 8 [136 Cal. Rptr. 409, 559 P.2d 1028].)
While appellant in the instant case is not exactly challenging proceedings subsequent to the plea, he is certainly not challenging the validity of the plea itself. This is the critical point about the nature of the appeal which makes section 1237.5 irrelevant.
Appellant does not seek to retract his admission that he committed the robbery as charged. He is challenging instead the trial court's act of sentencing him to five years and eight months instead of to three years. He does not argue that the plea bargaining process was invalid, nor that he *916 entered his plea as the result of any misrepresentation by the court. Rather, he argues that even though he expressly agreed to the court's keeping open the option of the longer sentence after initial sentencing and referral to CRC, neither of the bargaining parties had the legal right to create this option.
If appellant prevails, the plea bargain which would remain enforceable is the original agreement announced by appellant and the district attorney at the June 22 disposition hearing. Under its terms appellant agreed to plead guilty to the count 1 robbery. The People agreed to: (1) dismissal of count 3, and (2) a maximum sentence of three years for the robbery, with the sentence on the car theft to run concurrently.
Under the plea bargain which the People seek to enforce, appellant agreed to plead guilty to robbery and to allow his sentence to be increased from three years to five years and eight months if he failed to cooperate with the CRC program. The People agreed to: (1) dismissal of count 3, and (2) to a sentence of three years maximum, with sentences on counts 1 and 2 to run concurrently, if appellant "cooperated" with the CRC program, and otherwise to a maximum of five years and eight months.
Therefore the issues on appeal have to do solely with the enforceability of one term of the plea bargain, and not with the validity of the plea. The question is not whether appellant is entitled to reversal, but whether he is entitled to the lower sentence.
The requirement of a certificate of probable cause under section 1237.5 is therefore not involved.

2. The trial court had no jurisdiction to impose a sentence based on occurrences subsequent to the commission of the crimes.

(1b) In the instant case the record shows that appellant was sentenced at the July 31, 1981, hearing when the judge said, "the defendant is sentenced to state prison for the term of three years." At the same time he also added the two-year term for car theft to run concurrently. There is no question that this sentence is what appellant had bargained for. The fact that at that same hearing the judge also reiterated the "condition" he wanted to impose requiring appellant to cooperate with the CRC does not alter our conclusion that appellant had been sentenced at that point.
Remarks made by the judge at subsequent hearings support this reading of the clear language in the record.
*917 At the hearing on August 21, 1981, the judge said, "the defendant has been previously sentenced...." And when reminded that sentence had to be imposed before the defendant could be referred to CRC, the judge said, "I did that. That has already been done. I did that at the last hearing on the matter."
And finally, at the hearing on April 2, 1982, when appellant had been returned to court because he had been determined to be not a fit subject for confinement or treatment at CRC, and appellant's counsel pointed out that his client had already been sentenced, the court said, "Well, I did it for purposes of complying with Welfare and Institutions Code section 3051." The judge's motive for sentencing is irrelevant; this statement, like his other remarks, makes it clear that he intended to sentence appellant at the July 21 hearing, and that he did so.
At the August 21, 1981, hearing the court committed appellant to the CRC. The statute governing such a commitment is Welfare and Institutions Code section 3051, which provides in pertinent part: "Upon conviction of a defendant for any crime in any superior court ... and upon imposition of sentence, if it appears to the judge that the defendant may be addicted or by reason of repeated use of narcotics may be in imminent danger of becoming addicted to narcotics the judge shall suspend the execution of the sentence and order the district attorney to file a petition for commitment of the defendant to the Director of Corrections for confinement in the narcotic detention, treatment, and rehabilitation facility...." (Italics added.)
Thus, at the conclusion of the August 21, 1981 hearing, appellant had been sentenced and committed to the custody of the Director of Corrections.
At the April 2, 1982 hearing, appellant had been returned to court having been found unsuitable for the CRC program because of his behavior and violence potential. The statute governing this procedure is Welfare and Institutions Code section 3053, subdivision (a): "If at any time following receipt at the facility of a person committed pursuant to this article, the Director of Corrections concludes that the person ... is not a fit subject for confinement or treatment in such narcotic detention, treatment and rehabilitation facility, he shall return the person to the court in which the case originated for such further proceedings on the criminal charges as that court may deem warranted."
While this language may seem to give the court wide discretion, it is necessarily limited by the procedural context in which the CRC referral occurs. The statute authorizing that referral by its terms requires the "imposition of sentence" before commitment, and requires the court to "suspend *918 the execution" of that sentence while the defendant is at CRC. (Welf. & Inst. Code, § 3051, italics added.)
The requirement of sentencing before commitment to CRC is a relatively recent legislative act. (Stats. 1980, ch. 822.) It is a reflection of the basic policy of determinate sentencing which now characterizes this state's penal system. The Legislature has ensured that a defendant committed to the narcotics rehabilitation program will be sentenced under the same statutes as others convicted of the same crime, and that the deprivation of liberty imposed on that defendant in the form of involuntary commitment to CRC will be no greater than that imposed on defendants sent directly to prison. (Welf. & Inst. Code, § 3201, subd. (c).) And specifically, "... the period of commitment, including outpatient status, for persons committed pursuant to Section 3051, which commitment is subsequent to a criminal conviction for which execution of sentence to state prison is suspended, shall equal the term imposed under section 1170 of the Penal Code...."
The "further proceedings" when the defendant is returned to court, to which Welfare and Institutions Code section 3053, subdivision (a) refers, are the proceedings necessary to execute the sentence. Once a legal sentence has been pronounced in open court and in the presence of the defendant, the trial court simply does not have jurisdiction to impose another, higher sentence at a later time. (See People v. Hartsell (1973) 34 Cal. App.3d 8, 14-15 [109 Cal. Rptr. 627].)
The situation of the instant case, where the defendant was referred to CRC but sent back to court because of unsuitability, is analogous to a defendant being placed on probation with sentence suspended and then being returned to court under Penal Code section 1203.2.
Rule 435 of the California Rules of Court provides that when a defendant is returned to court after revocation of probation, if execution of sentence has been suspended, the judge shall order it to be in full force and effect and send the defendant to prison. And even if the imposition of sentence had been suspended, the length of the sentence to be imposed at that point must be "based on circumstances existing at the time probation was granted, and subsequent events may not be considered...." (Rule 435, subd. (b)(1).) This restriction is based on In re Rodriguez (1975) 14 Cal.3d 639 [122 Cal. Rptr. 552, 537 P.2d 384]. (Advisory Com. com., [Deering's Ann.] Cal. Rules of Court, rule 435, [(1980 ed.)].)
The Rodriguez case concerned sentencing practices of the Adult Authority under the old indeterminate sentence law, but its reasoning stemmed from the Eighth Amendment prohibition against cruel and unusual punishment. *919 The court's discussion in Rodriguez is illuminating: "This basic term-fixing responsibility of the Authority is independent of the Authority's power to grant parole and of its discretionary power to later reduce the term thus fixed, which fixed, constitutionally proportionate, term we shall hereafter refer to as the `primary term.' The Authority's power to grant parole and to later reduce the primary term remain unaffected. That power enables the Authority to give recognition to a prisoner's good conduct in prison, his efforts toward rehabilitation, and his readiness to lead a crime-free life in society. On the other hand, this discretionary power also permits the Authority to retain a prisoner for the full primary term if his release might pose a danger to society [citation] and to revoke parole, rescind an unexecuted grant of parole and refix a reduced term at a greater number of years up to the primary term if the prisoner or parolee engages in conduct which affords cause to believe he cannot or will not conform to the conditions of parole, or would pose a danger to society if free. [Citations.] These considerations, however, are based in large measure on occurrences subsequent to the commission of the offense. [¶] Conversely, the primary term must reflect the circumstances existing at the time of the offense. Both the Eighth Amendment and article I, section 17, proscribe punishment which is disproportionate to the particular offense." (In re Rodriguez, supra, at p. 652.)
In effect, the trial court's actions in the instant case amounted to a statement to the defendant as follows: "You have pled guilty to robbery and been convicted of car theft. For these crimes you deserve the punishment of three years in state prison. Because you are an addict, I must refer you to CRC. And if you fail to cooperate at CRC, you will receive the additional punishment of two years and eight months in state prison." Such a posture is not permissible. It violates not only the Eighth Amendment of the federal Constitution and article I, section 17 of the California Constitution, but it also is inconsistent with the express policy of the Legislature as expressed in Penal Code section 1170, subdivision (a)(1): "The Legislature finds and declares that the purpose of imprisonment for crime is punishment. This purpose is best served by terms proportionate to the seriousness of the offense with provision for uniformity in the sentences of offenders committing the same offense under similar circumstances." (Italics added.)
It was the obligation of the trial court in the instant case to sentence appellant according to the provisions of the determinate sentencing statutes, and consistently with the constitutional principles explained in Rodriguez. The only valid basis for a sentence was the crimes of which appellant had been convicted, and not his later behavior at CRC. The trial court simply did not have the power to resentence appellant based on occurrences subsequent to the commission of his offenses.
*920 Because the resentencing based on appellant's behavior at CRC was not within the jurisdiction of the court, the fact that the plea bargain included this as an option is irrelevant. Under the statute governing plea bargains, the agreement "may specify the exercise by the court ... of other powers legally available to it." (Pen. Code, § 1192.5, italics added.) (3) A criminal defendant does not have the power to confer jurisdiction on the court by agreement which it would not otherwise have. (See 1 Witkin, Cal. Procedure (2d ed. 1970) Jurisdiction, § 10, pp. 534-536.)

Conclusion:
Because we find that this case is controlled by the Rodriguez case, we do not discuss the parties' other contentions.
(1c) Appellant is entitled to be committed under the terms of the sentence which was imposed on July 31, 1981. The abstract of judgment is hereby ordered to reflect the sentence of three years for robbery as the principal term, and two years for car theft, with the sentences to run concurrently.
Feinberg, J., and Barry-Deal, J., concurred.
NOTES
[1]  The reporter's transcript reflects that counsel referred to "section 3054 of the D & I Code." The "D & I" Code would seem to be a typographical or transcription error, as counsel obviously was referring to the Welfare and Institutions Code. Also, counsel's reference to section 3054, both at the hearing and in the written arguments filed appears to be a mistake, as the obviously relevant section is 3053.
