Amanda Bynes won't be punished for drug possession if she agrees to attend twice-weekly counseling sessions and avoid trouble for the next six months.

Last May, the actress threw a bong outside her window during a police raid on her New York City apartment. She was charged with reckless endangerment, tampering with evidence and marijuana possession.

Bynes, 27, was hospitalized for mental health issues until December so the case was delayed. Her lawyers have been working with authorities to make a plea deal.

During a hearing on Friday, a judge approved the agreement and ruled that the case will be adjourned in contemplation of dismissal. Bynes was not in court during the ruling, but her attorney Gerald Shargel submitted an affidavit declaring that she understood the terms of the deal.

Bynes will not have to admit any guilt, but she must undergo regular counseling for six months and avoid further legal troubles during that period.

Meanwhile, the actress still must go to trial for a charge of driving under the influence (DUI) for a 2012 arrest in 2012 where she allegedly side-swiped a police car in California. A pre-trial date has been set for next month, but her attorneys are trying to reach a plea agreement in that case as well.