
622 So.2d 1371 (1993)
Ronald E. BARRETT, Appellant,
v.
STATE of Florida, Appellee.
No. 92-2300.
District Court of Appeal of Florida, Fourth District.
September 1, 1993.
Richard L. Jorandby, Public Defender, and Eric M. Cumfer, Asst. Public Defender, West Palm Beach, for appellant.
*1372 Robert A. Butterworth, Atty. Gen., Tallahassee, and James J. Carney, Asst. Atty. Gen., West Palm Beach, for appellee.
STONE, Judge.
We reverse Appellant's judgment and sentence because the record reflects that Appellant entered a plea to a life felony with respect to which a habitual offender sentence is invalid. Lamont v. State, 610 So.2d 435 (Fla. 1992). An invalid sentence may be attacked by direct appeal. Adamo v. State, 496 So.2d 252 (Fla. 4th DCA 1986); Wickett v. State, 467 So.2d 430 (Fla. 4th DCA 1985).
We cannot determine from the record whether the court and parties understood that Appellant was charged with a life felony, or whether they were under the impression that attempted first degree murder with a deadly weapon was a first degree felony. At best, the record and written judgment are ambiguous in this regard. There is no indication in the record that the state ever reduced this charge to a first degree felony. Also, the record reflects that both the court and the prosecutor referred to Appellant's plea as being to the crime as charged, that is, committed with a deadly weapon. Additionally, the written sentence makes specific reference to section 775.087(1), Florida Statutes, which reclassifies the degree of this felony from first degree to life, for use of a weapon.
We reject Appellant's request that we simply strike the habitual offender portion of his sentence by this opinion, leaving the balance of his sentence untouched. It appears that Appellant's plea was negotiated, involved the nolle prosse of two other counts, and apparently would not have been accepted by the court but for Appellant's agreement to habitual offender treatment. As the state points out, all parties acted on the assumption that Appellant qualified as a habitual offender, and Appellant should not be permitted to renege on a portion of his agreement with impunity. We also note that the trial court expressed a preference, at the sentencing hearing, for sentencing Appellant to life in prison if afforded that option.
Therefore, on remand, if the Defendant does not agree to imposition of the same sentence on an amended information, the state is to be afforded the opportunity to withdraw from the plea agreement and reinstate the initial charges, and the trial court shall also have an opportunity, if applicable, to reevaluate whether to accept a plea on any proposed terms not contained in the initial sentence. See Morris v. State, 620 So.2d 1081 (Fla. 2d DCA 1993); Dolan v. State, 598 So.2d 291 (Fla. 5th DCA 1992); Daniels v. Smith, 478 So.2d 110 (Fla. 2d DCA 1985).
DELL, C.J., and DOWNEY, JAMES C., Senior Judge, concur.
