Courts treat plea agreements between prosecutors and defendants like contracts: To fail to stick to one is to breach it. But if the parties haven't finalized the agreement in court, the prosecution might be able to back out of it.
In most courts across the country, the prosecution can usually back out of a plea deal until the defendant actually enters the plea in court and the judge accepts it. (See Pleading Guilty: What Happens in Court.) But even where prosecutors are free to back out of not-yet-official plea deals, courts must protect defendants' rights: If the prosecution backs out, it may not be able to use at trial any statements the defendant made during plea negotiations.
Courts in many places consider statements inadmissible if a defendant makes them in reasonable reliance on the possibility of a plea deal. In other words, even if the prosecution and defense have merely discussed a deal that the prosecution doesn't later consummate, statements by the defendant during plea negotiations may be inadmissible.
The American Bar Association (ABA) created Prosecutorial Function Standard 3-4.2(c), a stricter standard for prosecutors, but most courts don't follow it. In essence, it provides that it's unprofessional for the prosecution to back out of a plea agreement once it offers one to a defendant and the defendant indicates that he accepts it. Even if the defendant hasn't had the chance to formally take the plea in court, the prosecution can't back out unless:
For example, the prosecution would be able to back out under this standard if the defendant skipped town, or if it found out that the defendant had prior convictions that it didn't know about.
Example: Prosecutors charge Bill with being part of a drug trafficking ring. His lawyer is negotiating a plea with them. The prosecution wants him to testify against the other guys in the ring. They work out a deal for Bill to testify in exchange for reduced charges. Bill signs a written plea agreement. But, before Bill can take the plea in court, the prosecution decides that it doesn't need his testimony after all. In most states, the prosecution would be able to back out of the deal, but wouldn't later be able to use statements Bill made during negotiations. In the states that follow the ABA standard, the prosecution probably wouldn't be allowed to back out. Bill having become unwilling to testify would have been a good enough reason, but no longer needing his testimony wouldn't have.
Keep in mind that different states may vary not only in whether they follow the majority rule or ABA standard, but also in other ways that define how and when either party can back out of a plea deal. This is part of why it is so important to talk to an attorney.
The law varies from one place to another (including from state to federal court), and the information in this article isn't exhaustive. Only an attorney familiar with the law in your area will know the circumstances under which the prosecution can back out of a plea deal, and whether any or certain statements during the negotiation process could be admissible in court. Professional legal advice is crucial for understanding not only whether the prosecution can back out of a deal, but also whether a particular prosecuting office is likely to.