The Supreme Court yesterday agreed to decide whether the Constitution allows judges to conduct entire criminal trials behind closed doors.

The court acted in a case from Hanover County, Va., in which a judge closed a two-day murder trial to the public and press.

Yesterday's action gives the court an opportunity to clarify widespread confusion arising from the so-called Gannett ruling handed down July 2, at the end of the term. The ruling upheld the exclusion of the public and media from a pretrial hearing on whether certain evidence should be suppressed.

In the 14 weeks since the ruling, 75 efforts to close criminal proceedings -- including 13 trials -- have been made around the country, according to the Reporters Committee for Freedom of the Press. Closure resulted in 44 cases, including six trials, the committee said.

The confusion arose mainly from language in the opinion for the court in which Justice Potter Stewart ranged beyond the immediate issue of the closing of a pretrial hearing.

The Sixth Amendment's guarantee of a right to a public trial is for the person accused of an offense and for "him alone," Stewart wrote. "The Constitution nowhere mentions any right of access to a criminal trial on the part of the public. . . ."

Of the four justices who signed his opinion, three wrote inconsistent separate opinions about the meaning and scope of the Gannett decision. And no fewer than five justices later publicly mentioned or discussed the decision, including some who have said that the court's opinions must speak for themselves.

The case also aroused deep concern among press and civil liberties organizations. A dozen have signed or offered friend-of-the-court briefs in the Virginia case, which involved the first secret trial in the 243-year history of Hanover County.

The case went to trial in September 1978 before Circuit Judge Richard H.C. Taylor. The defendant, John Paul Stevenson of Baltimore, was accused of killing a local motel manager.

It was Stevenson's fourth trial. The first, in 1976, resulted in a conviction, but the Virginia Supreme Court nullified it because inadmissible evidence had been introduced. The second and third efforts ended in mistrials. The grounds were not disclosed in the final trial, which ended with an acquittal. These first three trials were open to the public and press.

As the 1978 trial was about to begin, defense lawyer C. Willard Norwood asked the judge to close the courtroom.

"There was this woman that was with the family of the deceased when we were here before," he said. "She had sat in the courtroom. I would like to ask that everybody be excluded from the courtroom because I don't want any information being shuffled back and forth when we have a recess as to what -- who testified to what."

Commonwealth's Attorney Patrick R. Bynum Jr., after establishing that reporters would be among those excluded, said that closure was up to the judge. Taylor then granted the defense motion.

In doing so, Taylor said his power derived from "the statute." This was a reference to a Virginia law -- similar to laws in many other states -- giving a trial judge discretion to "exclude from trial any persons whose presence would impair the conduct of a fair trial, provided that the right of the accused to a public trial shall not be violated."

The judge acted without giving notice or an opportunity for a hearing to members of the public or the press, and without first determining whether Stevenson's right to a fair trial could be protected by an alternative, such as a change of venue or sequestering of the jury.

Taylor's order barred two reporters from Richmond Newspapers Inc., Timothy B. Wheeler and Kevin McCarthy. As a result, the newspapers asked the judge to open the trail. In argument late in the first day of the trial, Richmond attorney Alexander Wellford charged that the exclusion order was a prior restraint of publication in violation of the First Amendment and "a novel form of censorship." He did not mention the Virginia law.

Defense attorney Norwood, vaguely mentioning the "difficulty" in trying Stevenson previously, said, "I didn't want information to leak out." This was a particular danger in a small community, he suggested.

The judge, denying the open-trial motion, remarked that the courtroom layout could be distracting to the jury. In a brief in the U.S. Supreme Court for Richmond Newspapers, Harvard law professor Laurence H. Tribe said, "the same entirely typical courtroom had been used to conduct public criminal trials for nearly 2 1/2 centuries . . Although of modest dimensions, the courtroom's configuration parallels that of literally hundreds throughout the land . . ."

Last July 9 the state supreme court rejected an appeal by Richmond Newspapers. Its brief order cited the Gannett ruling handed down seven days earlier.

Virginia Attorney General Marshall Coleman urged the U.S. Supreme Court to leave the order standing, on the ground that it had no jurisdiction because the state law hadn't been challenged at trial or on appeal. Yesterday, the high court said it will hear argument on its jurisdiction and on the merits.

Tribe said the justices have "a ripe opportunity" to decide whether the Gannett ruling will "install a regime of secret prosecutions alien to our history and our traditions." At least, he said, they should lay down "precise criteria" for courtroom closings.

But the reporters committee and seven other press groups urged the Supreme Court to do more. It should "reverse or substantially modify" Gannett, they said.

Including the four dissenters in Gannett and earlier statements by three members of the Gannett majority, Chief Justice Warren E. Burger and Justices Lewis F. Powell Jr. and John Paul Stevens, the American Newspaper Publishers Association and the American Society of Newspaper Editors counted seven justices who have said that criminal trials must be open.