Anatoliy F. Dobrynin, ambassador of the Union of Soviet Socialist Republics and dean of the diplomatic corps, said goodbye to Washington last night after 24 years of cold wars and warm friendships, sputniks and satellites, dissension and de'tente. As he put it, "I have known six presidents and nine secretaries of state. It was quite an experience." He joked about people who go to Russia and write long books after short stays, saying, "Should I go back and write, it would probably fill the Library of Congress."

Dobrynin flies home tomorrow. His own Aeroflot jet, symbol of his new status as general secretary of the Soviet Communist Party's Central Committee, is poised in readiness at Andrews Air Force Base. The ambassador turned down all offers of farewell parties except one: Secretary of State George Shultz's small luncheon for him yesterday at the State Department.

Last night the party at the Russian Embassy on 16th Street was on Dobrynin. And he invited his diplomatic colleagues a little early so he could transfer to Swedish Ambassador Wilhelm Wachtmeister the post of dean of the diplomatic corps.

Shultz was also there as the ranking U.S. official. In his reply to Dobrynin's speech, the secretary told a story out of the Oval Office. Only Monday, he said, President Reagan had told him what a nice man Dobrynin is. And when someone commented to the president about the ambassador's new post in the Communist Party, Reagan replied, "You mean all along he's been a Communist?"

But Shultz, with a perfectly straight face, said that last night at least, Dobrynin was still an ambassador. "He's still working right up to the wire. He drafted his final cable today, analyzing the election of Clint Eastwood as mayor of Carmel, California. That's one I want to read."

Shultz said he gave Dobrynin a State Department chair a few months ago and that in return the ambassador gave him a clock. "We'll enjoy those as soon as our security agents finish taking them apart and putting them back together," he added.

The secretary said that unlike most ambassadors who come to see him, Dobrynin never takes notes. "We can't tell whether he's wired for sound or he's using poetic license."

Some reporters who were denied access covered the party from the Siberia of the sidewalk.

Shultz, who may or may not have realized there was a freeze-out of the party (social) press, joked: "Ambassador Dobrynin has ordered a news blackout of this event because he doesn't want Moscow to learn about the violation of the Brezhnev doctrine [theoretically, once a Communist country, always a Communist country]. This is the first time ever a Communist has handed over power to a count."

Wachtmeister is a count in the Swedish nobility, and as the new dean, he gave Dobrynin the traditional ambassador's farewell gift of a plaque.

Thanking Wachtmeister for the gift, Dobrynin said that with the plaque, which features the Washington Monument and the U.S. Capitol, he would "never have problems parking in Moscow."

Sixteenth Street between L and M was double-parked with long black limousines, protected by their diplomatic plates and manned by chauffeurs in smart caps.

Wachtmeister, in his formal remarks, said, "Anatoliy, as you move to an influential post in your country's leadership, your deep knowledge of the U.S. will no doubt be a great asset for your government to the benefit of increased understanding between these two great nations." Sen. Edward M. Kennedy, who came late and joined an impromptu receiving line in the great hall after the formal one had broken up, echoed Wachtmeister's sentiments.

* "He will be in an important role in the Soviet Union shaping policy, and one of my conclusions from visiting there was that there are gross misconceptions about the U.S., its values and interests," Kennedy said. "And Ambassador Dobrynin has had an opportunity to gain some real impressions, and his voice in terms of those policies can be very important. We'll have to wait and see."

Sen. Gary Hart, asked to assess the impact of Dobrynin's departure, said, "I think it leaves a vacuum, but if he can help the arms control issue from the Kremlin, then that's to everyone's advantage."

In a Beaux Arts setting worthy of a czar (one actually bought the embassy before the Russian Revolution from the Pullman car heirs) Washingtonians jostled each other to shake hands with Dobrynin and his wife Irina. For a time, Shultz stood in the receiving line with the Dobrynins, as did Wachtmeister.

Dobrynin, who was injured in a fall on the ice during his last trip to Moscow, used a cane but talked at length to guests. Irina Dobrynin, in a green brocade dress and a leaf pin, told guests that her granddaughter, who was with them much of the time, had left several months ago for Moscow.

After they paid their respects, the guests surrounded the long, white-clothed tables in the grand salon and in the wood-paneled dining room. The feast, in typically lavish Soviet fashion, included salmon, crowns of lamb and even American watermelon. In a smaller salon were the desserts. If there was caviar, it disappeared before most guests could reach the tables. Soviet aides pointed out to guests that the red wine being served came from Soviet Georgia and was a favorite of Joseph Stalin. Guests said they saw no evidence of that Russian staple, vodka, bringing home Mikhail Gorbachev's new hard line against vodka consumption.

* It fell to Shultz to remind everybody of the good old days.

Dobrynin, he said, once told him that he had learned two things from former secretary of state Dean Rusk. One was how the U.S. system works, the other how to drink bourbon. "We hope you won't tell them in Moscow what you learned about the first, and we're sure from what we've read of the new policies that you won't tell them about the second -- the no-vodka rule," said Shultz.

But there was a serious note in Shultz's farewell to Dobrynin, whom he called "Anatoliy" at one point. "You have been a witness to a quarter of a century of our history," he said. "You have often had to tell us things we didn't like to hear. And you have often had to listen to things you didn't like to hear. But you have done it with dogged determination. Your departure marks a new era. You're going to an even more important post."