The Carter administration, having failed to persuade the deposed shah of Iran to remain in Panama, nevertheless asserted yesterday that it does not believe Iran will put its American hostages on trial for espionage or take other harsh action against them.

Administration officials were uncertain about whether the deposed monarch's flight to Egypt over the weekend will further set back efforts to resolve the 146-day-old hostage crisis. But they seemed confident that, despite the threats coming out of Tehran, Iranian authorities will confine their reaction to angry rhetoric rather than reprisals against the hostages.

Noting that the Iranians are aware that espionage "show trials" would have a negative effect on world opinion and force a tough response from the United States, a senior U.S. official said: "We do not regard trials or similar actions as a very probable outcome."

He recalled that while the Iranians reacted with a flood of angry threats to the Jan. 29 escape of six Americans who had been hidden in the Canadian Embassy in Tehran, the status and treatment of the hostages did not change.

Operating on an assumption that the deposed shah's whereabouts are not the key to winning release of the hostages, the administration nonetheless sought to keep him in Panama for fear of adding another element of uncertainty to the elaborate waiting game the United States has been playing for weeks with Iranian authorities.

Senior administration officials continued to insist that the deposed shah, Mohammad Reza Pahlavi, decided on his own to seek sanctuary in Egypt and that he retains a commitment from the administration that he may return to the United States for "emergency medical treatment" if he so desires.

But the officials described fulfillment of that commitment as "hypothetical" and "improbable," making it clear, as they said it is clear to the shah, that American officials would not welcome his return to the United States for any purpose as "the best option."

From the comments of these officials and others, the picture that emerged of the shah is of a man who was unhappy in Panama, knew he was not truly welcome in the United States and so fled to Egypt, the one country where he hoped to find both welcome and comfort.

The shah's flight, which was preceded by a high-level U.S. effort to persuade him to remain in Panama, was the latest twist in the more than four-month-long drama over the fate of the American hostages.

It touched off a wave of speculation and charges that some of the shah's powerful friends, including former secretary of state Henry A. Kissinger and New York banker David Rockefeller, had intervened in his behalf and sought to gain his readmission to the United States.

However, administration officials denied that Kissinger or Rockefeller played any role in the rapidly developing events, and they said the shah, knowing the attitude of the U.S. government, never asked to be readmitted.

The officials also dismissed last-minute suggestions by Iranian authorities that the hostages would be taken out of the custody of the Iranian militants and turned over to Iranian government officials if the shah remained in Panama.

One of the underlying assumptions of administration policy is that Iran authorities realize that the shah will never return to Iran and that prolonging the stalemate will damage their country.

Another reason the adminstration sought to keep the shah in Panama was the knowledge that his only other viable haven was Egypt, where his presence could exacerbate fundamentalist Moslem hostility toward President Anwar Sadat and complicate the Egyptian's negotiations with Israel on the future of Israeli-occupied Arab territories.

For these reasons, President Carter last Thursday dispatched his chief of staff, Hamilton Jordan, to Panama with express orders to keep the shah in Panama if possible.

Jordan's immediate concern was a dispute between Panamanian authorities and a team of American doctors, headed by noted Houston heart surgeon Michael E. DeBakey, who had examined the shah earlier and determined that he urgently required removal of a swollen and probably cancerous spleen. DeBakey, however, insisted on control of operating-room facilities and procedures during the surgery, ruffling the feelings of Panamanian medical and government authorities, who threatened to block the surgery.

Jordan stopped first in Houston to confer with DeBakey, then flew to Panama, where by Friday, according to administration officials, he had worked out a compromise that would have allowed the American doctors to operate on the shah in Panama. On Friday, Carter also dispatched his White House counsel, Lloyd Cutler, to Panama to inform the shah of the compromise that would allow him to remain in Panama.

By all accounts, however, by the time Jordan and Cutler reached Panama, the shah already was determined to go to Egypt. Neither the shah nor his wife, administration officials said, felt comfortable or welcome in Panama, and both were unhappy with their lives on the resort island of Contadora.

The shah informed Cutler of his decision Friday night, and the White House official asked him to reconsider overnight. But when Cutler visited the shah again Saturday, the shah's answer was the same -- he was going to Egypt.

Since the beginning of the hostage crisis, U.S. policy toward Iran has taken some abrupt changes of direction.

The administration's initial approach emphasized trying to isolate Iran by seeking to apply an escalating series of pressures such as economic sanctions, and by threatening military action such as a naval blockade of Iran.

However, that posture changed after the Soviet invasion of Afghanistan, Iran's neighbor, last Dec. 27. The invasion transformed the situation from a U.S.-Iranian test of wills to a contest between Washington and Moscow for influence in the Persian Gulf region, with its vital oil supplies.

Since January, the U.S. effort has stressed conciliation and a search for compromise solutions, such as the United Nations commission initiative that was supposed to pave the way for the hostages' release last month. That effort failed when Iranian moderates shrank from a showdown with the hostages' militant captors.

The administration has shifted to a position of waiting to see if the struggle between Iran's divided power centers will tip the balance toward the moderates and allow a resumption of the U.N. commission's work. But it probably will take several weeks to see if that strategy has any hope of success.

State Department spokesman Hodding Carter reaffirmed yesterday that U.S. policy continues to emphasize "two major thrusts" -- the safe release of the hostages and the effects of the parallel Afghanistan crisis on Iran and the Persian Gulf region. But, he stressed, the freedom of the hostages is the dominant consideration.

When the shah left the United States for Panama last Dec. 15, U.S. officials, without saying so publicly or explicitly, made known that they had given him a commitment to help him obtain proper medical care in a health emergency.

But the nature of the commitment was never spelled out. Although U.S. sources insisted yesterday that it did not preclude the possibility of the shah's returning to this country if other options were unavailable, the sources acknowledged that what they called "the play of forces" involving the hostages' welfare had been stressed in making clear to the shah that he wasn't wanted here.

Initial efforts to sort out the reasons for the shah's departure from Panama were complicated by a spate of conspiracy rumors.

Kissinger, who was in New York yesterday, authorized an aide here, William Hyland, to say, "All these reports of my involvement are disgusting lies."

Hyland added that Kissinger had not been in Panama recently, as Iranian Foreign Minister Sadegh Ghotbzadeh has alleged, and has had no contact with any of the governments or individuals involved. Kissinger has not spoken to the shah except for a brief courtesy telephone call "roughly 48 hours after the shah arrived in Panama," Hyland said.

He quoted Kissinger as saying, "These are governmental responsibilities, with lives at stake, and I am not going to involve myself." Kissinger, Hyland insisted, "was not informed or consulted by the State Department, and he played no role in the events."

Similarly, a spokesman for the Chase Manhattan Bank in New York said that neither David Rockefeller nor any other employe of the bank had discussed the shah's status with the U.S. government or Panamanian authorities since last October, when the shah entered the United States for treatment.

Administration officials also dismissed as "a fairy tale pure and simple" the suggestion that the United States or Panama had offered to keep the shah in Panama until Iran presented a formal request for his extradition if Iran would arrange the transfer of the hostages out of the militants' control. While Iranian officials might have suggested such a trade-off, the U.S. officials said, it was clear that the Iranians do not have the power at this point to challenge the militants effectively.