Whether Andrei Andreyevich Gromyko was a principal architect of the policies he expounded over nearly three decades as Soviet Foreign Minister, or simply their loyal executor, remains a mystery shrouded in his loyalty to the cause he served so long. What is clear is that Stalin, Nikita S. Khrushchev and Leonid I. Brezhnev all found him indispensable in turn. But Mikhail S. Gorbachev finally found him an obstacle to his program for sweeping change in Soviet internal and external affairs and ended Mr. Gromyko's 28-year tenure as Foreign Minister in July 1985 by easing him upstairs to the ceremonial post of the presidency. Mr. Gromyko had been the instrument of Mr. Gorbachev's accession to the leadership of the Soviet Communist Party in March 1985, going before his aging colleagues in the Politburo then to tell them that it was time to cede the leadership to a younger man. Later, after Mr. Gromyko retired, he wrote his memoirs - revising them in 1989 as ''Memories,'' published in Britain by Hutchinson - and said he had decided himself to retire as President in October 1988 because he felt old and out of touch. In April 1989, he was dropped from his last position of power as a member of the Politburo, in a sweeping purge of the old guard by Mr. Gorbachev. By that time, Soviet policies associated with the cautious Mr. Gromyko were being swept aside with dizzying speed. In what Mr. Gorbachev called ''new thinking,'' one arms reduction proposal followed another, and the Soviet grip over Eastern Europe relaxed, allowing Hungary and Poland to evolve in political directions Mr. Gromyko described as counter-revolutionary when they first surfaced decades earlier. The Soviet military intervention in Afghanistan that he and his colleagues had decided on in 1979 was openly derided 10 years later as a costly mistake. Thus ended an extraordinary diplomatic and political career that had begun in 1939 when Foreign Minister Vyacheslav M. Molotov called Mr. Gromyko, a postgraduate student not yet 30 years old, to the Foreign Ministry. In the years that followed, he traveled to most of the countries of the globe, met and outlived the greatest statesmen of the age. Present at the creation of the United Nations, he never missed a General Assembly session until he left the Foreign Ministry. He was the first professional diplomat to be elevated to the Soviet Communist Party's ruling Politburo, and he was one of the few members who did not drink, even before Mr. Gorbachev took over and decreed abstemiousness as one of his first reforms. He was the able spokesman for many different Soviet policies over the years. He was ''Mr. Nyet'' in the cold war, the ''new Gromyko'' during the period of detente, and the dour and gruff exponent of a tougher line in Afghanistan and Poland in later years. While Mr. Gromyko was new to office, Khrushchev, who had appointed him, told a group of foreign ambassadors, ''If I tell my Foreign Minister to sit on a block of ice and stay there for months, he will do it without back talk.'' As he acquired experience, Soviet officials acquired more respect for him, and gradually the Foreign Ministry became his personal preserve. Foreign diplomats agreed that he always seemed to be in charge and superbly in command of his material. Mr. Gromyko's career was closely bound up with the United States. In the spring of 1939, when he was a researcher at the Academy of Sciences' Institute of Economics in Moscow and learning English, Molotov had him transferred to the Foreign Ministry, most of whose experienced men had been eliminated in Stalin's purges. He was put in charge of the American section, and six months later found himself in Stalin's office, where the dictator announced that he was sending him to the embassy in Washington as second in command. In 1943, Stalin appointed him Ambassador to the United States. After the war, he moved to New York for the first sessions of the United Nations, living at first in a Plaza Hotel suite. There - in the belly of the capitalist beast, as he later put it in ''Memories,'' translated by Harold Shukman - he confirmed a view of America that stayed with him all his life: ''Profit is the pitiless filter through which everything to do with culture and art and the country's spiritual life has to pass. Only that which promises a return on capital can survive.'' The future Foreign Minister was named Andrei Burmakov when he was born on July 18, 1909, in the village of Stariye Gromyki, in what is now Soviet Byelorussia. The local baptismal and official records, for Andrei and nearly everybody else in the village, listed the family name as ''Gromyko.'' His father, Andrei Matveyevich, was a literate peasant who had served in the Czar's army in the Russian-Japanese war and worked at odd jobs around the village. After the war and the revolution, Andrei finished primary and trade schools. Later he attended a technical school near Minsk, where he joined the Communist Party in 1931, and, that same year, he met and married Lidiya D. Grinevich, a fellow student he described as the daughter of Byelorussian peasants. The couple preserved an affectionate relationship through their long marriage, occasionally holding hands at diplomatic receptions. The Gromykos had two children and five grandchildren. A daughter, Emiliya, studied history and later married a Soviet diplomat, Aleksandr S. Piradov, an ambassador at large. A son, Anatoly, born in 1932, also entered the diplomatic service, served at one point in the embassy in Washington and has been director of the Africa Institute of the Academy of Sciences in Moscow since 1976. The young Mr. Gromyko also studied economics and Marxist theory at an institute in Minsk, then went to Moscow for the economics research that he left for diplomatic work. During World War II, Stalin and President Roosevelt carried on Soviet-American relations largely by themselves, and Mr. Gromyko's job then, as throughout his life, was to take care of the details. Yet he evidently had a certain amount of Stalin's trust. In the summer and fall of 1944, Mr. Gromyko helped conceive the United Nations in talks held by the United States, Britain and the Soviet Union at Dumbarton Oaks in Washington. He urged successfully that each of the major nations should have veto power, and after he became the first permanent Soviet representative to the United Nations in 1946, he used it - 25 times before he left the post in Juy 1948. But he also voted with the majority on occasion. In 1947, for instance, he supported the resolution for partition of Palestine into Jewish and Arab states. He had become a Deputy Foreign Minister when he was moved to the United Nations, and in 1949 he became a First Deputy Foreign Minister in Moscow under Molotov's successor, Andrei Y. Vishinsky. He often acted as Foreign Minister during Mr. Vishinsky's illnesses and vacations. This period came just after the Soviet blockade of Berlin in the winter of 1948-49, and during the formation of the military alliances of the North Atlantic Treaty Organization and the Warsaw Pact, and later the Korean War. In 1952 Mr. Gromyko was sent to London as Ambassador to the Court of St. James's, and he was there when Stalin died in March 1953. In the jockeying for power that followed, Molotov again became Foreign Minister, and brought Mr. Gromyko back to Moscow as his First Deputy. As Khrushchev consolidated his power over the next few years, Molotov fell out of favor, and in February 1957, Mr. Gromyko became Foreign Minister. As long as Khrushchev held power, Mr. Gromyko was treated like a lackey, but he bore the indignities loyally. In his memoirs, Khrushchev described him as ''a good civil servant who always went by the book.'' He made light of Mr. Gromyko's professional thoroughness. A Western diplomat who met Mr. Gromyko at disarmament talks in Geneva in 1959 remembered him with awe. ''He had the American, British and French Foreign Ministers - Christian A. Herter, Selwyn Lloyd and Couve de Murville - standing on their heads,'' the diplomat recalled. ''And Gromyko was speaking in English at that. It was a real performance.'' Few of the great East-West foreign policy issues of the next few years bore Mr. Gromyko's mark. Khrushchev was too colorful a personality. When the Soviet leader took off his shoe and banged it on his desk at the United Nations in 1960, Mr. Gromyko did not follow suit. The bottom left corner of his mouth turned down even further than usual, and he simply scowled. In American eyes, Mr. Gromyko's status sank even further during the Presidency of John F. Kennedy. In the Cuban missile crisis of October 1962, he appeared to American officials to be either ignorant of the facts or lying about them. At the height of the confrontation, after the United States had gathered photographic evidence of Soviet construction of missile bases in Cuba, Mr. Gromyko met with President Kennedy, on Oct. 17, but acted as though he knew of no missile emplacements. Robert F. Kennedy later recounted the scene in his memoir, ''Thirteen Days:'' ''President Kennedy listened, astonished, but also with some admiration for the boldness of Gromyko's position. To avoid any misunderstanding, he read aloud his statement of Sept. 4, which pointed out the serious consequences that would arise if the Soviet Union placed missiles or offensive weapons within Cuba. ''Gromyko assured him this would never be done, that the United States should not be concerned. After touching briefly on some other matters, he said goodbye.'' Shortly after that, President Kennedy ordered a naval blockade to stop Soviet shipments of strategic missiles to Cuba, and the Russians backed down. Some think Mr. Gromyko never knew about the bases. In his own memoirs, he insisted: ''Contrary to later assertions made in the West, at no time in our conversation did Kennedy raise the question of the presence of Soviet rockets in Cuba; consequently there was no need for me to say whether there were any there or not.'' The debacle of this ''Caribbean crisis,'' as the Russians call it, was one of the reasons for Khrushchev's ouster two years later. Only after Khrushchev's removal did Mr. Gromyko really begin to come into his own. The new collective leadership, with Brezhnev and Aleksei N. Kosygin soon emerging at the top, left Mr. Gromyko in his key position at the Foreign Ministry. But the years after 1964 saw the emergence of the ''new Gromyko'' and of a foreign policy of a different order from the bluster, blunder and boast of the Khrushchev years. Diplomats noticed that the usually dour Foreign Minister smiled more often and even made a discreet joke. He seemed to become more his own man. In these years, the alliance with China dissolved in ideological and territorial rivalry. Soviet control over Eastern Europe threatened to break up with the short-lived 1968 liberalization in Czechoslovakia but was reaffirmed with the Soviet-led invasion. ''The Soviet people are under no obligation to ask for permission to intervene when issues of world peace and the freedom and independence of peoples are involved,'' Mr. Gromyko said later. ''That is our right as a world power.'' For all the assertiveness of that statement, the focus of Soviet foreign policy in the Brezhnev-Kosygin-Gromyko era was not confrontation but detente with the West, necessitated by the growing rift with China. Mr. Gromyko was entrusted with the details, the negotiations, the treaty texts and the technical agreements that gave detente shape and life. Loyally as always, he did the party's bidding in this as in so much else, but he was also acquiring stature and authority. It was he who negotiated the Soviet-West German treaty of 1970 in which Bonn recognized the postwar division of Europe, the existence of East Germany and the loss of the former German territories. Then, in a 1971 treaty with the United States, Britain and France, the Soviet Union agreed to normalize the status of West Berlin. Talks on limiting both sides' long-range bombers and missiles carrying nuclear weapons became the linchpin of the improving Soviet-American relationship in the early 1970's and, at least for a while, were the basis for continued good relations even after detente came under strain. Mr. Gromyko became as closely identified with the process as Brezhnev. Most Western diplomats in Moscow came to believe that by the end of the decade Mr. Gromyko was as much involved in formulating Soviet foreign policy as he was in expounding it. The first strategic arms agreement was reached after President Nixon went to Moscow in May 1972 for talks with Brezhnev. The negotiations produced a treaty limiting defensive antiballistic missile systems on both sides, and another, expiring in 1977, limiting offensive weapons. Soon after that, Brezhnev and his colleagues decided that it was time to bring Mr. Gromyko into the central decision-making group, and he was elevated to full membership in the Politburo on April 27, 1973. With this greater status, Mr. Gromyko went to Helsinki, Finland, in July 1973 to promote another Soviet diplomatic initiative - a conference on European security and cooperation to achieve the long-sought Soviet goal of Western recognition of the postwar division of Europe. The Foreign Minister's authority held, and as time went on and Brezhnev's health began to fail, the Soviet leader increasingly left his foreign policy to Mr. Gromyko. The two traveled to Vladivostok in 1974 to meet with President Ford on guidelines for a second treaty to limit strategic arms. The real bargaining began after the Carter Administration took office in January 1977, with Mr. Gromyko by then the key figure on the Soviet side. Secretary of State Cyrus R. Vance startled the Russians in March 1977 with new proposals to go beyond the Vladivostok agreement. But Mr. Gromyko called a televised news conference March 31 and rejected the proposals. His remarks were polished, touched with anger and sarcasm, as he accused the United States of seeking unilateral advantage. But he also said Moscow had ''enough patience to continue negotiations on all these problems.'' For more than two years, he and Mr. Vance met in Moscow, Washington and Geneva to work out the details of a new treaty, which was signed by Mr. Carter and Brezhnev in Vienna in June 1979. But the accord was never ratified. A New Freeze With U.S. The move into Afghanistan sent American-Soviet relations into a deep freeze at the beginning of 1980, and thus began the third phase of Mr. Gromyko's diplomatic career. About this time the leaders of the Soviet Union began to be crippled by age and poor health. First Brezhnev, in 1982, and then his two immediate successors, Yuri V. Andropov and Konstantin U. Chernenko, died in office. Until 1985, when Mr. Gorbachev came to power, the United States and the rest of the outside world had to go through Mr. Gromyko to deal with the Kremlin. And as personified by Mr. Gromyko, the Soviet leadership in those years was increasingly intractable and irascible, insisting on a martial law crackdown against the Solidarity movement in Poland, rejecting calls from a United Nations majority to pull out of Afghanistan, and rebuffing President Reagan's proposals to eliminate Soviet and American medium-range missiles from Europe. After the NATO alliance decided in 1983 to deploy American medium-range missiles in Europe to match Soviet SS-20's, the Russians walked out of negotiations, ushering in a period some feared would be a new cold war. When Moscow was ready to break the ice, Mr. Gromyko was the emissary, coming to the United Nations in the fall of 1984 to meet with Mr. Reagan. Early in 1985, he met in Geneva with Secretary of State George P. Shultz to start a new framework for dealing with space-based systems and nuclear arms. But Mr. Gromyko was to call the shots in those negotiations for only a few more months. In March 1985, after Mr. Chernenko's death, he took the floor in a closed session of the Central Committee to nominate Mr. Gorbachev as the new Soviet leader. ''This is a man of principle, a man of strong convictions,'' he said. ''I can personally confirm this.'' Revealing how the younger man had run leadership meetings during Mr. Chernenko's illness, Mr. Gromyko said of his abilities in foreign affairs: ''Mikhail Sergeyevich has spoken out on many occasions, including Politburo meetings, on how essential it is for us, as they say, to keep our powder dry.'' He is reported to have said of Mr. Gorbachev, ''Comrades, this man has a nice smile, but he has iron teeth.'' That July, Mr. Gromyko became the Soviet President. Mr. Gorbachev replaced him in the foreign affairs post with a man with little diplomatic experience, Eduard A. Shevardnadze. The move was a master stroke, at once honoring Mr. Gromyko for his decades of service and ending any threat he might pose to Mr. Gorbachev. From then on, Soviet policymaking in foreign affairs were clearly the province of Mr. Gorbachev and the advisers of his choice -Mr. Shevardnadze and Anatoly F. Dobrynin, the former Ambassador to the United States. When Mr. Reagan and Mr. Gorbachev met for their first summit meeting in Geneva in November 1985, Andrei Gromyko was the man who wasn't there.