The discussions of the prosecution and defense are conducted in private. One reason for this practice is that anything discussed in private cannot be used in the prosecution of the case. If the discussions happened in open court, witnesses might hear. Then, these witnesses could testify about the case. So, it serves your benefit to allow this to happen. If the discussions with the prosecutor and your attorney do not yield a satisfactory disposition, the matter goes to judicial pretrial.
Most courts have a judge who controls the criminal docket. This judge is called the presiding judge. This judge will sit as the final arbiter of the matter before the case goes to trial.
After a judicial pretrial, the court will make an offer. They will want to resolve the case after hearing from the prosecution and the defense lawyer. The sides often propose different disposition possibilities and the judge listens to both sides to determine a reasonable disposition given the legal and factual claims both sides make. If you, your attorney and the state agree on a disposition of the case you may be required to do a number of different things. Some of these things involve paying a fine, completing alcohol counseling, or complying with probation.
If you plead guilty to a crime (something which is punishable by some period of jail time) the judge must ask you a series of questions to determine if you are pleading to the information (the charges) knowingly and voluntarily. These questions ask you to waive your right to have a trial, act as a witness on your own behalf, call witnesses, or defend against witnesses against you and remain silent. The judge must also agree to give you the disposition which you agreed to take. If the judge does not approve, the judge must allow you to withdraw your plea. Over the next few court appearances, the prosecution and your defense lawyer discuss the merits of your defenses.
If you would like assistance with the negotiations process, you can contact an attorney. A lawyer can help you through this process and make sure that your rights are protected. They will have your best interested in mind and make negotiations for your benefit.