This case involves nothing more than a simple, albeit novel, question of contract law: Did the defendants repudiate or breach their plea agreements in collaterally attacking their convictions when, because of a change in the law, the conduct to which they pled guilty was no longer a crime? We conclude that they did not, and therefore reverse.
I. Background
Defendants Jose Maria Sandoval-Lopez and Joaquin Sandoval-Lopez were indicted on federal drug trafficking charges. They were also charged with two counts each of using or carrying a firearm in the commission of a drug trafficking offense, in violation of 18 U.S.C. § 924(c)(1) (the “gun counts”).1 On the fourth day of trial, they accepted the government’s offer of plea bargains. Under the plea agreements, the defendants each pled guilty to the two gun counts. In return, the government agreed to drop the drug trafficking charges and to ask that the defendants be sentenced to ten years (five per count), which the parties and the court all believed was the mandatory minimum under the statute. The district court initially accepted the pleas on those terms.
Subsequently, however, the district court determined that the defendants’ sentences had been calculated incorrectly, and that the proper sentence for two gun counts was twenty-five years (five for the first count and twenty for the second). It then issued an order to show cause why the defendants should not be permitted to withdraw their pleas. In response, the parties submitted a “Sentencing Stipulation/Resolution,” in which they agreed that if the district court imposed the agreed-upon ten-year sentences, the government would waive its right to appeal the calculation error, and the defendants would stipulate “that they, each, are not aggrieved for purposes of appeal by virtue of the Court’s not imposing terms of incarceration greater than ten years as the Court was otherwise obligated.” The district court approved the stipulation and entered judgment, sentencing each defendant to ten years in prison, and the defendants commenced serving their sentences.
Nine months later, the Supreme Court issued its decision in Bailey v. United States,-U.S.-, 116 S.Ct. 501, 133 L.Ed.2d 472 (1995), holding that the “use” prong of *799§ 924(c)(1) “requires evidence sufficient to show an active employment of the firearm by the defendant, a use that makes the firearm an operative factor in relation to the predicate offense.” Id. at-, 116 S.Ct. at 505. In so holding, the Court changed what had been the settled understanding in this circuit as to the statutory definition of “use.”2 The defendants then filed motions under 28 U.S.C. § 2255 «collaterally attacking their convictions on the basis that the conduct to which they.had pled guilty was no longer a crime. The district court properly granted those motions and vacated the defendants’ convictions, concluding that the government had not produced sufficient evidence to establish violations under either the “use” or the “carry” prong of § 924(c)(1).3 Subsequently, the district court issued an order holding that the defendants had breached their plea agreements by challenging then-convictions, and therefore that the government was no longer bound by its promise regarding the dismissed drug trafficking charges. The district court also held that the Double Jeopardy Clause did not bar reinstatement of the dismissed charges, despite the facts that (a) the government and the defendants did not agree on plea bargains until the fourth day of trial, and (b) the defendants did not waive double jeopardy under the terms of the plea agreements. The district court then ordered the drug charges reinstated and ruled that the government was entitled to retry the defendants on the previously-dismissed counts. While the defendants’ service of their sentences terminated when the district court vacated then-convictions on the gun counts, they remained in custody pending trial on the reinstated drug charges.
On appeal, the defendants contend that they may not be tried on the drug charges, arguing (1) that the district court erred in concluding that they breached their plea agreements, (2) that both parties are still bound by those agreements, and (3) that the government is therefore precluded from reinstating the dismissed counts and subjecting the defendants to a further trial on them. As a separate ground, the defendants contend that, even if the plea agreements are no longer binding, reinstatement of the charges violates the Double Jeopardy Clause. The government seeks to uphold the reinstatement of the charges solely on the ground that the defendants repudiated or breached their plea agreements. We conclude, to the contrary, that no breach or repudiation occurred, and we therefore reverse.
II. Jurisdiction
The parties appear to be in agreement that we have appellate jurisdiction over the claim that the government is barred by the plea agreements from reinstating the dismissed charges, as well as over the related double jeopardy claim. We have an obligation, however, to consider the question of our jurisdiction sua sponte. See WMX Technologies, Inc. v. Miller, 104 F.3d 1133, 1135 (9th Cir.1997) (en banc). We conclude that we have jurisdiction over both claims under 28 U.S.C. § 1291. Both are based on the identical facts and seek the identical relief. Only the legal theories differ. Indeed, both claims involve the same concerns and are subject, for the same reasons, to the collateral-order rule of Cohen v. Beneficial Indus. Loan Corp., 337 U.S. 541, 69 S.Ct. 1221, 93 L.Ed. 1528 (1949). See Abney v. United States, 431 U.S. 651, 659-63, 97 S.Ct. 2034, 2040-42, 52 L.Ed.2d 651 (1977). As in the case of its ruling that double jeopardy does not apply, the district court’s conclusion that the government is not barred by the plea agreements from subjecting the defendants to trial on the drug counts because they breached or repudiated those agreements *800“constitute[s] a complete, formal, and, in the trial court, final rejection” of their claim, id. at 659, 97 S.Ct. at 2040; the elements of the claim “are completely independent of [the defendants’] guilt or innocence,” id. at 660, 97 S.Ct. at 2040; and the defendants’ rights would be “significantly undermined if appellate review ... were postponed until after conviction and sentence.” Id. at 660-61, 97 S.Ct. at 2040-41.
III. Analysis: The Contract Claim
Plea bargains are contractual in nature and subject to contract-law standards. See United States v. Read, 778 F.2d 1437, 1441 (9th Cir.1985). Just as with other forms of contracts, a negotiated guilty plea is a “bargained-for quid pro quo.” United States v. Partida-Parra, 859 F.2d 629, 633 (9th Cir.1988). Thus, either party can be said to “breach” a plea bargain if it fails to live up to the promises it made under the terms of the agreement. Where a defendant has breached a plea agreement, courts have found the government to be free from its obligations. See, e.g., id. (citing United States v. Verrusio, 803 F.2d 885, 887-89 (7th Cir.1986); United States v. Reardon, 787 F.2d 512, 516 (10th Cir.1986)). Where the government is in breach, there are several available remedies, including allowing the defendant to withdraw his guilty plea or ordering “specific performance” by the government. See id. at 633. (citing United States v. Herrera, 640 F.2d 958, 960 (9th Cir.1981)); see generally Fed.R.Crim.P. 32(e) (governing plea withdrawals).
In accordance with standard contract-law principles, if the government is correct that the defendants breached or repudiated their plea agreements in this case, it is no longer bound by its promise to dismiss the drug trafficking charges and is free to reinstate the dismissed counts insofar as they are not barred by double jeopardy. If no breach or repudiation occurred, the government’s argument fails and the defendants are entitled to hold it to its promise with respect to the dismissed drug counts.
Although there was no written plea agreement in this case, the Assistant United States Attorney explained to the district court the substance of the plea bargains:
The offers were that the defendants, Jose Maria Sandoval Lopez would enter a guilty plea to Counts 8 and 9 of the Indictment; [and] Joaquin Sandoval Lopez would enter a guilty plea to Counts 11 and 12 of the Indictment4 ... with the stipulations by Jose and Joaquin Sandoval Lopez with the requisite predicate offenses exist, narcotics offenses existed under the current Ninth Circuit law for this Court to impose two consecutive five-year sentences; and, further, that there will be no opposition on the seizures, forfeitures of cars, currency, weapons or cellular telephones in this case that might arise and give rise to a double jeopardy argument.
The defendants ... are willing to enter pleas to those counts of the Indictment with the stipulations.
The government argues that under the plea agreements the defendants promised (1) to plead guilty to the gun counts, (2) to serve ten years imprisonment, and (3) not to challenge their convictions or their sentences; therefore, it argues, the defendants breached or repudiated their plea agreements when they filed their § 2255 motions, and the government is no longer bound by its promise to dismiss the drug counts. The only basis on which the government contests the defendants’ claim that the charges may not be reinstated is the alleged breach or repudiation.
We conclude that, in this most unusual case, the government attempts to claim benefits under the plea agreements that it never contracted for and therefore is not now entitled to receive. In United States v. Pruitt, 32 F.3d 431 (9th Cir.1994), we held:
A plea agreement does not waive the right to bring a § 2255 motion unless it does so expressly. The government gets what it bargains for but nothing more.
*801Id. at 433. According to the representations the Assistant United States Attorney made to the district court, the only promises the government extracted from the defendants in exchange for dismissing the drug trafficking counts were that (a) they would each plead guilty to committing the gun counts (which, the government concedes, are no longer crimes in light of the evidence it could have presented at trial), and (b) they would not challenge the forfeiture of their property on double jeopardy grounds. As for the sentencing stipulation, the only promise the defendants made to the government was that “they, each, are not aggrieved for purposes of appeal by virtue of the Court’s not imposing terms of incarceration greater than ten years as the Court was otherwise obligated” — in other words, that they would not appeal their sentences as being unlawful because they were shorter than provided by statute. That promise applied solely to the defendants’ right to bring a direct appeal of their sentences on a particular, and unusual, ground5 and did not in any way purport to limit their right to challenge the constitutionality or legality of their convictions in collateral proceedings.
In short, whatever the prosecution could have bargained for, it chose to require of the defendants only that they not challenge the forfeiture of their property on double jeopardy grounds and that they not appeal their sentences as violative of the mandatory minimum sentencing requirement. The agreement left the defendants free to file § 2255 motions if at any time they perceived there to be a problem with their pleas, or if for any other reason they concluded that their convictions or sentences were improper; see Pruitt, 32 F.3d at 433; as a result, the prosecution bore the risk that a change in the relevant substantive law would afford the defendants the right to be released. See United States v. Bamhardt, 93 F.3d 706, 708 (10th Cir.1996) (“[A] plea of guilty does not bar a claim that the defendant’s conviction is unconstitutional ‘no matter how validly his factual guilt is established’ if the facts he pled guilty to are subsequently determined not to be criminal.” (quoting Menna v. New York, 423 U.S. 61, 63 n. 2, 96 S.Ct. 241, 242 n. 2, 46 L.Ed.2d 195 (1975))).
At the time of the pleas, there was reason to believe that a change in the law regarding the gun counts might occur in the near future. Petitions for certiorari in the consolidated cases that comprise Bailey were filed on December 28-29, 1994, more than two months prior to the date on which the defendants were sentenced in accordance with the plea agreements. There was a circuit split as to the statutory meaning of “use,” and, even within the circuits, there were widely divergent and contradictory results.6 Finally, even if the prosecution had no reason to expect that a specific change in the law regarding the gun counts might occur and result in the invalidation of the defendants’ convictions on those counts, it still knew or should have known that comparable changes in the law occur from time to time.7 Not*802withstanding the above, the prosecution chose to take the pleas on those counts alone and failed to provide for any right to reinstate the drug charges should the gun count convictions subsequently be vacated.8
It is important that in the present case the defendants challenged only the validity of their convictions on the gun counts and did not attack the plea agreements themselves. Defendants sometimes bring collateral attacks on the plea agreements qua plea agreements, by claiming that their pleas were not “knowing” or “voluntary,” or were otherwise defective. Such attacks are directed at the entire agreement, and, if successful, may render the entire agreement void or voidable. Had the defendants brought that type of challenge, and had the district court determined that their claims were valid, the proper remedy might have been to vacate or allow withdrawal of the guilty pleas and reinstate the dismissed charges. See, e.g., Taylor v. Kincheloe, 920 F.2d 599, 601, 605-06 (9th Cir.1990) (allowing reinstatement of dismissed charges after defendant demonstrated he did not understand consequences of plea agreement); United States v. Barker, 681 F.2d 589, 592-93 (9th Cir.1982) (affirming vacation of order dismissing indictment after successful attack on plea bargain on basis that defendant had not been adequately informed as to nature of charge to which she pled guilty). In such case, the government might have legitimately asserted that the defendants repudiated the plea agreements.
The defendants did not attack their plea agreements, however. Instead, they claimed in their § 2255 motions that, while their plea bargains were knowing, voluntary, and in all other respects proper when made and ac-. eepted by the district court, the conduct to which they pled guilty — the only conduct for which they were convicted and sentenced — is now insufficient as a matter of law to support their convictions. They did not recant their admissions to having committed the acts that formed the basis for the counts of conviction; they simply claimed, correctly, that after Bailey those acts were no longer crimes.
As we said at the outset, this is a simple contract case. The government contends that because the defendants breached or repudiated their plea agreements it may now subject them to trial on drug charges that were previously dismissed. Unfortunately for the government, the defendants neither breached nor repudiated the agreements. They merely did what the agreements permitted them to do. The government is therefore not free to reinstate the dismissed counts. Given our holding, we need not decide the double jeopardy question.9
IV. Conclusion
We reject the government’s argument and the district court’s order that the defendants may now be tried on the dismissed drug charges. Accordingly, we reverse and remand with instructions to dismiss the drug charges with prejudice.
REVERSED AND REMANDED.
. Section 924(c)(1) provides, in part:
Whoever, during and in relation to any crime of violence or drug trafficking crime ... for which he may be prosecuted in a court of the United States, uses or carries a firearm, shall, in addition to the punishment provided for such crime of violence or drug trafficking crime, be sentenced to imprisonment for five years.... In the case of his second or subsequent conviction under this subsection, such person shall be sentenced to imprisonment for twenty years....
18 U.S.C. § 924(c)(1).
. Compare United States v. Torres-Rodriguez, 930 F.2d 1375, 1385 (9th Cir.1991) (pre-Bailey case holding mere possession of gun sufficient to constitute “use” under § 924(c)(1)), with United States v. Davis, 76 F.3d 311, 314-15 (9th Cir.1996) (post-Bailey case recognizing that mere possession or presence of gun is insufficient to constitute "use,” even if gun serves to embolden or protect defendant).
. The government conceded both in the district court and on appeal that it could not establish violations of § 924(c)(1) under either prong. It argued, however, that the defendants should not be permitted to bring the § 2255 challenges, or that, in the alternative, the dismissed counts from the original indictment should be reinstated.
. Counts 8, 9, 11, and 12 are the gun counts.
. While it is hard to imagine why a defendant would ever be "aggrieved” by receiving a sentence shorter than the statutory minimum, the language the government chose when it drafted the sentencing stipulation makes clear that the only requirement it imposed on the defendants was that they not appeal their sentence as being too short. The unusual promise the government requested resulted from the fact that the government was providing the defendants with unusually favorable treatment. As a result, the government decided to be cautious in its sentencing agreement — but not cautious enough.
. See generally Bailey,-U.S. at---, 116 S.Ct. at 504-05 (detailing history of inconsistent interpretations given statutory definition of “use” by circuit courts).
. To set forth just one example, in McNally v. United States, 483 U.S. 350, 107 S.Ct. 2875, 97 L.Ed.2d 292 (1987), the Supreme Court held, contrary to the interpretation widely adopted in the lower courts, that § 1341 of the mail fraud statute, 18 U.S.C. § 1341, did not protect "intangible rights.” Id. at 356, 107 S.Ct. at 2879. What followed was a rash of cases both on direct appeal and on § 2255 motions overturning convictions for violations of § 1341. See, e.g., United States v. Mitchell, 867 F.2d 1232 (9th Cir.1989) (granting § 2255 relief); United States v. Egan, 860 F.2d 904 (9th Cir.1988) (reversing conviction on direct appeal); United States v. Dadanian, 856 F.2d 1391 (9th Cir.1988) (granting petition for rehearing and reversing conviction on direct appeal).
. We do not indicate any view as to whether under the circumstances of this case an agreement permitting reinstatement of the drug charges would be lawful.
. We avoid constitutional questions when an alternative basis for disposing of the case presents itself. See, e.g., Ashwander v. Tennessee Valley Auth., 297 U.S. 288, 347, 56 S.Ct. 466, 483, 80 L.Ed. 688 (1936) (Brandeis, J., concurring).