A federal judge in Alexandria yesterday ordered the State and Justice department to help two men charged with spying on behalf of Hanoi to contact the Vietnamese ambassador to the United Nations who left the country last week.

The ambassador, Dinh Ba Thi, who was named as an unindicted coconspirator in an espionage case, is needed for questioning by attorneys for Ronald L. Humphrey and David Truong are charged with stealing classified diplomatic cables and passing them to an international network of Vietnamese communist agents.

The attorneys said they need to talk to Thi because he may have information to prove their clients are innocent.

The State Department requested that Thi leave the country as a result of the espionage allegations. At first Thi refused to leave, but he was later recalled by his country, the Socialist Republic of Vietnam.

Last week Bryan signed an order directed at keeping Thi in the country so the lawyers could determine if the ambassador was a material witness.

Bryan said yesterday he assumed under his order the State Department would lift its earlier request that the ambassador leave because of the allegations against him. Because that action was not specifically spelled out in the order, the State Department did not tell Thi of the judge's ruling. Thi left the country.

Bryan suggested yesterday that government prosecutors, who readily agreed to the order, may have tried to trick him into signing it, knowing the order would not have effect Bryan wanted.

Bryan said he and defense attorneys "should heve smelled a rate, but we didn't."

"I have a feeling that maybe the government's ready consent to the order last week may have been disingenous," Bryan said. "We're not here to play games."

Assistant U.S. Attorney James R. Hubbard said the government had not intention of trying to trick the judge and that any action now could step on delicate diplomatic toes since the U.S. and Vietnam do not have formal diplomatic relations.

"When (Thi) was recalled, we felt the matter was out of our hands," Hubbard said.

Hubbard said was the responsibility of Humphrey and Truon's lawyers to contact Thi, not the government's.

Bryan disagreed. "You can imagine how far a private citizen can get placing a telephone call to Hanoi to talk to Mr. Thi," he said.

In the end Bryan blamed the government for the diplomatic mess and ordered the State and Justice departments to aid Humphrey and Truong in asking Thi if he would testify in their case.

Last night Hubbard said the State Department agreed to deliver any messages to the ambassador through both government's liaisons in Paris.