Surgeons yesterday sealed off a leaking passageway inside James S. Brady's skull and left the operating room "cautiously optimistic" that they have solved a problem that has threatened his recovery.

For nearly three hours a George Washington University Hospital team explored, then repaired a group of sinuses shattered when Brady was hit by a bullet that entered his brain, and which were a pathway for cerebrospinal fluid that was leaking from his nose.

After the surgery he was in stable condition, coherent and "chattering away," according to a doctor who visited him.

It was the fourth major operation for the White House press secretary, who was shot in the March 30 assassination attempt on President Reagan.

It may not be the last operation. It will be several weeks before the surgery's effectiveness can be evaluated fully, according to the operating surgeons, Drs. Norman Barr Jr. and Arthur Kobrine.

But "it looks like a very, very good chance" that Barr and Kobrine found the site of the leak, and if this is true their repairs "should provide a good seal," according to Dr. Dennis O'Leary, GW medical spokesman.

Brady's most recent "spinal-fluid" leakage began Aug. 3, probably triggered by pressure within his skull caused by a sudden epileptic-like seizure that threw him into a day-long coma.

But the cause of the problem was the bullet. It shattered into bits after it penetrated Brady's skull just above his left eye, and left a devastating trail of bone and bullet fragments.

The main area of damage, other than the destruction when it reached the brain, was in the sinuses, a bony labyrinth of spaces behind and above the upper nose. Full repairs were impossible on March 30.

Spinal fluid leakage through this area forced a hastily scheduled operation on the night of April 22. Brady had to be operated on again on May 4 to keep dangerous blood clots from his lungs.

In the latest operation, beginning at 8 a.m. yesterday, the surgeons made a 1 1/4-inch incision starting at his left eyebrow and reaching down the left side of his nose. Working in this confined space, they explored the frontal and the small ethmoid sinuses on the left side of the head.

They removed several bone and bullet fragments. Then, through the cleared area, they could see the apparent site of the most recent spinal fluid leakage: a quarter-inch gap in the bony roof of the rearmost ethmoid sinus, on the underside of the skull.

They carefully packed this sinus and others with fat from Brady's belly to establish, they said, "an effective seal."

For a week or more, O'Leary said, Brady's activity will be "pretty constrained" to promote healing. Then, it is hoped, he will begin renewed physical therapy and a course toward recovery.

His spirits, friends say, have remained good, and were good Tuesday night, when he was allowed to leave the hospital to go to dinner.