OPINION OF THE COURT
Tom, J.P.Defendant appeals from a judgment convicting her, on her guilty plea, for her peripheral role in the sale of a small quantity of drugs to an undercover police officer. Defendant contends that she is entitled to specific performance of a negotiated plea agreement, having fulfilled her obligations thereunder, and notes that the three-year sentence imposed by the court is longer than that meted out to any direct participant in the sale. She seeks to replead to a class A misdemeanor and to be sentenced to a term of no more than one year.
Defendant was charged with third-degree criminal sale of a controlled substance arising from her role as a lookout for two codefendants in a sale of four “zips” of crack cocaine to an undercover police officer. On July 16, 2009, defendant entered into a written plea and cooperation agreement with the District Attorney’s office, which provided that defendant agreed to plead guilty to the class B felony charge contained in the indictment and to provide information concerning criminal activity in her neighborhood, particularly drug sales. If defendant complied with the provisions of the plea agreement, the People would recommend that she be permitted to replead to seventh-degree criminal possession of a controlled substance and receive a term ranging from a minimum, nonjail sentence, with probation, to a maximum sentence of one year of imprisonment. The plea agreement provided that the People have sole discretion to determine if defendant’s cooperation was satisfactory and whether she had complied with its terms.
*4The court expressed reservations about defendant entering into a cooperation agreement, noting that it had “suggested drug treatment for [defendant] from the beginning,” and warned defendant that the “temptation is going to be very big” to resume using drugs once out on the streets. The court then took defendant’s allocution pursuant to the terms of the plea agreement and released her on her own recognizance.
In October 2010, the People provided the court with a confidential status report, which stated that defendant’s cooperation had been affected initially by illness, as revealed by hospital records. However, in February 2010, defendant “began providing good information” to the police, and also participated in “controlled drug buys,” resulting in the issuance of search warrants and four arrests.
The People noted that defendant was “well known” in the neighborhood where she lived and was providing cooperation. Since entering into the agreement, a drug supplier refused to deal with her due to rumors that she was working with the police and defendant was “confronted by an individual who was arrested as a result of information given by her to police.” The People also noted that defendant “has children who live in the neighborhood, and whose whereabouts are known to some of the individuals who have been arrested based upon [her] cooperation with the police.” Noting her “diligent cooperation in the last seven months,” the court was advised that the People were “considering whether to make a favorable recommendation to the Court at the time of sentencing.”
At the next court appearance on December 1, 2010, the prosecutor had the courtroom sealed and requested that the court seal the minutes. The court responded that it had not been kept apprised of the progress of the case after asking on a number of occasions to be kept informed. The court then stated it had no idea why the courtroom should be closed and the minutes sealed.
The court further stated that the prosecution had put “[defendant] back to the street to hang out with the same people that she has been hanging out with all of her life, so that she could continue to supply you with, I don’t know what.” The court added, “[N]ow in clear full fashion she’s pregnant again with, what is it, five or six other children that she has none of, whom she is the mother to.” The prosecutor again requested that the minutes be sealed, explaining that there were “things that [defendant] has been doing” pursuant to the plea agree*5ment, which the People did not want to put “on the record if the minutes are not sealed.” When the court refused to seal the minutes, the prosecutor asked to be permitted to approach the bench to explain. The court refused to permit the parties to approach and refused to seal the minutes, concluding that “the People don’t want to be heard.” Defense counsel then stated that the People would be “requesting to dismiss the indictment.” The court stated that it would not “dismiss the indictment or anything else” unless the prosecutor “persuades me to do it.” Defense counsel asserted that it would not be “wise” to proceed “unless there is a sealing of the record because her life is in danger.”
The court refused to hear defense counsel and briefly left the courtroom. Upon returning, the court reiterated that it would not seal the minutes and would not permit counsel to approach the bench. The court concluded that it was “totally uninterested in this case or what you want done with it because there is nothing.” The court added, “I can’t even feel bad for [defendant] here, I don’t think she is worthy of sympathy. I don’t think she has shown the slightest sign of reforming her life. Nothing.”
On January 6, 2011, the prosecutor and defendant’s attorney appeared before the court without defendant. The prosecutor informed the court that defendant had given birth earlier that week and had been discharged from the hospital on January 4. The prosecutor again asked permission to approach the bench, but the court refused, stating, “[A]fter your little detour and foul up, I have no idea what [defendant] has been doing the last couple of years, other than getting pregnant.” The court added, “[F]rankly, she didn’t look like she was about to give birth to me. I understand she is a small woman. That does indicate certain other things. I’m not a doctor or anything.” The court stayed issuance of a bench warrant for one week pending the People’s inquiry.
On January 13, 2011, the People and defendant appeared in court, without her attorney. The prosecutor noted that, after defendant gave birth, a Family Court Judge determined that in order for her to obtain custody of her baby, defendant would have to undergo inpatient drug treatment. Supreme Court ordered an “enhanced IS!]” noting that “there is a condition that [defendant] participate in a residential treatment in the meantime.”
In accordance with the agreement, the People recommended that defendant be permitted to plead to a misdemeanor and be *6sentenced to time served in view of her fulfillment of her obligations under the instrument. The presentence report recommended a sentence of probation, and a letter dated May 18, 2011 from the District Attorney’s office attested to her full satisfaction of the cooperation agreement.*
The People detailed the extensive cooperation that defendant had provided through January 2011, noting that she had “participated in several street level operations with the [police] in July of 2009.” Defendant’s cooperation was thereafter hampered for several months by several hospital admissions due to gastrointestinal issues. The People asserted that defendant admitted to smoking marijuana during this period, “to ease nausea,” and warned defendant that such activity “could result in a violation of the agreement.” Defendant recovered and, beginning in February 2010, provided information which led to 13 arrests, recovery of “felony and misdemeanor quantities of narcotics,” and “controlled drug buys that resulted in nine search warrants.” Defendant “also provided information relating to thefts and trademark counterfeiting.” The People provided details as to the significant amounts of contraband that was recovered through defendant’s assistance, including over 90 “zips” of crack cocaine, at least one-quarter ounce of other cocaine, 7 glassines of heroin, over 50 zips of marijuana, 325 pills, and over 3,000 counterfeit sneakers and handbags.
The People noted that defendant’s efforts had “adverse consequences” for her, as local drug dealers labeled her a “snitch.” By the fall of 2010, the People learned that defendant was pregnant. At that time, the People “determined” that, given the “length of [her] cooperation, the number of cases that resulted from [her] work, as well as the increasing number of members of [her] community who had become suspicious of her, particularly several higher level drug dealers,” they were “prepared to ask the Court to terminate the cooperation agreement, and recommend that the defendant be permitted to re-plead to a misdemeanor.”
The People further noted that on January 15, 2011, defendant was arrested in a “domestic violence incident” and charged with attempted third-degree robbery. However, the case was dismissed. Additionally, on April 22, 2011, defendant was arrested and charged with third-degree identity theft.
*7On May 11, 2011, the parties appeared for sentencing. The court indicated that it did not intend to follow the People’s recommendation and berated the People for leaving defendant in a “toxic environment,” where her need for treatment — both for drug addiction and mental health issues — went unmet. The court further chided the prosecutor for failing to keep it apprised of defendant’s status. Defense counsel asserted that although he too had not favored the plea agreement as reached, the fact remained that “the People have gotten the benefit of this particular bargain. They got everything they wanted of her.” Counsel thus sought “specific performance of the plea agreement.”
The court refused to follow the People’s recommendation and sentenced defendant to a term of three years, plus three years’ postrelease supervision. The court also ordered that defendant be placed in a comprehensive alcohol and substance abuse treatment (CASAT) program in an alcohol and substance abuse correctional annex (see Penal Law § 60.04 [6]), with “[m]edical attention and psychiatric attention.” The court further stated that it would “have no objection to early release” if defendant completed the CASAT program.
While a plea agreement is not a contract and the courts retain discretion to pronounce an appropriate sentence (see People v McConnell, 49 NY2d 340, 346 [1980]; Matter of Randolph v Leff, 220 AD2d 281, 281 [1995]), that discretion “is not absolute” (Randolph, 220 AD2d at 281-282). A defendant who has “performed services for the prosecutor, at risk to himself,” absent “compelling reasons” is entitled to “receive the benefit of his bargain” through specific performance of the plea agreement (People v Danny G., 61 NY2d 169, 175-176 [1984]). A court, in declining to honor a plea agreement, despite a defendant’s performance thereunder, must provide “legitimate reasons on the record” (People v Grimaldi, 200 AD2d 687, 689 [1994]; see Danny G., 61 NY2d at 174).
The court explained that it declined to abide by the plea agreement based on the People’s failure to keep it apprised of defendant’s status, and because defendant had engaged in drug use and been rearrested. The court’s assertion that the People failed to keep it apprised of defendant’s status is not supported by the record which indicates that the People supplied the court with a status report in October 2010. At the December 1, 2010 court appearance, the prosecutor reminded the court of the October status report when the court stated it had not “a clue *8as to what has been happening in this case.” The court then concluded that the report “told me nothing, a little bit too little too late.” The prosecutor offered to “fill in any blanks,” to which the court responded that it had no interest in an update. In any event, the plea agreement does not require the People to keep the court informed of defendant’s status, and defendant should not be penalized for the People’s purported shortcomings in this regard.
The court’s decision to ignore the People’s recommendation to sentence defendant to time served, based on her continuing drug use, is not a legitimate reason, under the circumstances, to refuse to honor the plea agreement. While noting that it did not have any drug test results before it, the court explained, “It’s simply circumstantial, but there was plenty of drug use involved here.”
There was evidence in the record that defendant engaged in drug use both before and after December 1, 2010, when the People determined that she had already complied with the terms of the plea agreement. The People’s May 2011 letter states that defendant admitted to smoking marijuana during the second half of 2009, ostensibly to ease nausea related to documented gastrointestinal illness. The plea agreement vested the People with sole discretion to determine whether defendant complied with its terms, including determination of whether she had committed additional crimes. The People were aware of this alleged drug use and nonetheless determined that defendant had complied with the plea agreement. Accordingly, the alleged drug use occurring prior to December 1, 2010 could not constitute legitimate grounds for refusal to honor the plea agreement.
As to the period after December 1, 2010, the People’s May 2011 letter asserts that, in January 2011, defendant failed to report to drug treatment mandated by the Family Court. The People also reported that, in April 2011, defendant admitted to a police officer that she regularly used heroin. However, such reports of continued drug use, occurring after defendant had already completed the services required by the plea agreement, were not sufficiently “compelling” to deprive defendant of the agreement’s benefits (Danny G., 61 NY2d at 176).
On appeal, the People take a different position on the issue of specific performance from the position they took at sentencing. In support of their appellate contention that circumstantial evidence of defendant’s use of drugs provided a legitimate basis for imposing a sentence at variance with the sentence she was *9promised, the People cite to People v Figgins (87 NY2d 840 [1995]) and this Court’s decision in People v Buglione (11 AD3d 297 [2004]). These cases are distinguishable. In both, the defendant’s violation involved an express condition of the negotiated plea agreement and did not, as here, involve conduct extraneous to the agreement. As to the People’s reliance on People v Jenkins (11 NY3d 282 [2008]), the result in that case appears to rest on the fact that the People would not join in the defendant’s motion to dismiss the indictment until documentary proof was received showing compliance with all the conditions of the agreement, and the matter was adjourned for the defendant to produce the documentation, leaving open the issue of the defendant’s compliance. The defendant was rearrested and violated other requirements of the plea agreement before his next court appearance and thus, the court was no longer bound by the plea promise. In the present case, the People, vested with sole discretion to determine defendant’s compliance with the agreement, acknowledged defendant’s compliance with and full satisfaction of the plea agreement at the time of sentence and recommended to the court that defendant be permitted to re-plead to a misdemeanor.
The subject plea agreement does not require defendant to refrain from drug use. Rather, it provides that should the District Attorney’s office determine that defendant “has committed any new or additional crimes,” the benefits bestowed by the agreement will be forfeited. Significantly, the People did not advise the sentencing court that defendant had committed any crime warranting departure from the agreed-upon sentence; nor did the court make a finding that defendant violated any provision of the agreement. At the time sentence was imposed, the only charge outstanding was a misdemeanor that was not a drug-related offense. The court did not undertake any inquiry into the circumstances of the arrest and the ultimate disposition of the charge is not disclosed. Furthermore, the District Attorney’s office took the position that any arrest or known drug use occurred after defendant had satisfied the terms of the cooperation agreement.
While a defendant is not generally entitled to strict enforcement of a negotiated plea agreement (see e.g. People v Selikoff, 35 NY2d 227, 238 [1974], cert denied 419 US 1122 [1975]), it is acknowledged that circumstances may warrant granting a defendant the consideration promised at the time that a guilty plea was entered, particularly where the defendant has changed *10his or her position in reliance on that promise (id. at 239). Even where a plea is made contingent on the defendant’s simply not being arrested during the term of the agreement (not, as here, on a determination by the District Attorney’s office that the defendant has committed an additional crime), the mere fact of arrest is insufficient to warrant departure from the negotiated plea and sentence; rather, the court is required to conduct a sufficient inquiry to afford the defendant an opportunity to demonstrate that the arrest was without foundation (People v Outley, 80 NY2d 702, 713 [1993]), an inquiry not undertaken here.
In this case, defendant provided information concerning criminal activity, particularly drug dealing, at considerable risk to herself and her children in situations where the People acknowledge providing no protection and in an area controlled by a notorious street gang. As noted in People v Danny G. (61 NY2d at 175), the paramount consideration in deciding whether the circumstances warrant specific performance of a plea agreement is the “concern that a defendant who has performed services for the prosecutor, at risk to himself, be treated fairly.” Since “the State may hold the defendant to the precise terms of the plea agreement . . . , as a matter of fairness, defendant should be entitled to no less” (id. at 174, citing People v McConnell, 49 NY2d 340, 349 [1980] [“a promise made by a State official authorized to do so and acted upon by a defendant in a criminal matter to his detriment is not lightly to be disregarded”]; but see People v Jenkins, 11 NY3d 282 [2008], supra). Here, in the course of her extensive cooperation with the police, defendant was identified by drug dealers in her neighborhood as a “snitch.” The People report that defendant’s children also live in the neighborhood, and their whereabouts are known to some of the persons who have been arrested as a result of defendant’s efforts. Thus, in rendering services pursuant to the agreement, defendant has incurred “risk,” both to herself and to her children, and cannot be restored to the status she maintained prior to entering into the agreement (Danny G., 61 NY2d at 175).
The record reflects that the court was dissatisfied with defendant’s decision not to abide by its advice to immediately seek substance abuse treatment rather than enter into the plea agreement that would place her back into the “toxic” elements of the streets and, as a result, defendant became the target of the court’s dissatisfaction throughout the proceedings, including at her sentencing. While the court’s advice to initially seek drug treatment was sound, nevertheless, defendant made a con-*11scions decision to enter into the cooperation agreement, which was approved by the court. Her value as an informant, of course, arose from her reputation as a known drug user and her ability to associate with drug dealers in order to gather incriminating information about their activities. That role obviously exposed her to recurrent drug use. The courts’ discomfort with that risk, however, should not obscure that defendant undertook the risk in making her decision. Since the People received the full benefit of the plea agreement to defendant’s detriment, it would be grossly unjust under the circumstances of this case to permit them to divest defendant of the benefit of her bargain.
A further concern arising from the court’s exercise of discretion which seems to undercut the court’s professed regard for defendant’s well-being is manifest in this case. During the proceedings, the court exhibited hostility, even disdain, toward defendant and, more importantly, a total disregard for her safety and welfare relating to her role as a drug informant for the District Attorney’s office. Courts have established precautionary protocols during court proceedings to protect the identity of undercover police officers working on drug-related matters due to the inherent danger of the work (see People v Alvarez, 51 AD3d 167 [2008], lv denied 11 NY3d 785 [2008]; People v Sanabria, 301 AD2d 307 [2002], lv denied 99 NY2d 632 [2003]). This prophylactic safeguard should be extended to drug informants such as defendant who are in the same if not a more precarious position, and unlike officers, are completely unprotected on the streets. Here, the trial court, in refusing to close the courtroom and seal the minutes at the urging of both the prosecutor and the defense, and denying the parties an opportunity to make out a prima facie showing for the closure, demonstrated another clear abuse of discretion, especially in light of the above-noted information that neighborhood drug dealers had threatened defendant and called her a “snitch.”
Our decision rests upon sound considerations of judicial policy. It has been consistently stated that plea negotiations are essential to the efficient functioning of the criminal justice system (see e.g. People v Avery, 85 NY2d 503, 506-507 [1995]; Selikoff, 35 NY2d at 233). While depriving a defendant of the benefit of a plea agreement might be justified on the ground that “the court and the People were entitled to insist on strict compliance with every term” (Jenkins, 11 NY3d at 287), whether express or implied, the perception fostered by an unduly rigid adherence to this principle may undermine the very feasibility of negotiated *12pleas. Though sustainable as a matter of law under certain circumstances, strict construction of plea agreements may facilitate “ ‘the detrimental effect on the criminal justice system that will result should it come to be believed that the State can renege on its plea bargains with impunity notwithstanding defendant’s performance’ ” (Danny G., 61 NY2d at 176, quoting McConnell, 49 NY2d at 349). Moreover, affording a court unfettered discretion in imposing sentence irrespective of the terms of a negotiated plea agreement or defendant’s substantial compliance therewith, as the People contend is required under Jenkins, even in the face of the trial prosecutor’s support for granting the defendant the benefit of the bargain, effectively renders illusory any promise they might have made to the defendant.
Under the circumstances presented here, the court improvidently exercised its discretion in declining to accept the People’s recommendation for sentencing under the plea agreement. The manner in which the court exercised its discretion was especially jarring when it is considered that the three-year term to which defendant, who acted as a lookout, was sentenced was greater than the 30-month and one-year terms received by her codefendants, who conducted the sales transaction. There is no record that those codefendants rendered the kind of extensive and dangerous services provided by defendant, and they, in fact, bore greater culpability for the underlying crime. Hence, for risking her life by providing the District Attorney’s office with information of drug transactions in compliance with a court-approved plea agreement, defendant is being penalized with a greater sentence of imprisonment than the direct participants of the underlying crime and was deprived of her bargained-for benefits under the agreement. The picture, as a whole, portrays a gross miscarriage of justice.
Accordingly, the judgment of the Supreme Court, New York County (Carol Berkman, J.), rendered May 18, 2011, convicting defendant, upon her plea of guilty, of criminal sale of a controlled substance in the third degree, and sentencing her to a term of three years, should be unanimously modified, as a matter of discretion in the interest of justice, to the extent of reducing the conviction to criminal possession of a controlled substance in the seventh degree, and reducing the sentence to time served, and otherwise affirmed.
Sweeny, DeGrasse, Abdus-Salaam and Manzanet-Daniels, JJ., concur.
*13Judgment, Supreme Court, New York County, rendered May 18, 2011, modified, as a matter of discretion in the interest of justice, to the extent of reducing the conviction to criminal possession of a controlled substance in the seventh degree, and reducing the sentence to time served, and otherwise affirmed.
At the time sentence was imposed, defendant had already been incarcerated prior to the plea for a period greater than the maximum sentence for the misdemeanor offense.