The late Philip A. Hart, a wry and understanding man from Michigan, would have smiled at the gyrations around his name yesterday on the Senate floor.

First, in the cause of setting an example of frugality, the Senate voted to mothball the partially completed office building that will carry the senator's name.

Then, regaining its collective senses, the Senate reversed itself and voted to proceed with the project, cutting some frills but still leaving it as the most expensive federal building in history.

As the cost stands now, with no assurance that it will not increase, the building will require $142.6 million, with completion scheduled for 1982.

Yesterday's action, adding $57.4 million to a $10.9 billion energy-water resource spending bill, now shifts the controversy into a House-Senate conference. The bill passed 90 to 6.

The House last year, in the backwash of Proposition 13 and perhaps even a twinge of envy, refused to approve money for continued work on the building, leaving it in a weird limbo of a massive steel framework next door to the Dirksen Office Buidling.

Yesterday's isue was getting the project back on the tracks in the Senate, where ever-rising cost projections have spurred new doubts about the need and prudence of a flashy new building.

It was nasty, so much so that Majority Leader Robert C. Byrd (D-W. Va.) $&(WORD ILLEGIBLE went rushing to the floor to admonish the skirmishers against getting so personal.

For almost three hours, senators railed at each other in one of those group floggings that the world's most exclusive club, as it is sometimes called, has become famous for.

As shifts of tourists-constituents looked on in bewilderment from the public galleries, the senators accused each other of demagoguery, grandstanding, hypocrisy, profligacy, elitism, short-sightedness and other endearing legislative traits.

The way it ended after all this was the adoption, by a three-vote margin, of the amendment to spend another $57.4 million on the building and to set its construction costs at $142.6 million.

In the reversal, after the vote to stop construction and several other parliamentary entanglements, the edge of victory was provided by Howard M. Metzenbaum (D-Ohio), who switched his vote, and Mike Gravel (D-Alaska) and Russell B. Long (D-La.) who had not voted the first time around.

The cheerless task of defending a project that began with a $48 million price tag in 1972 fell to J. Bennett Johnston (D-La.), chairman of the Senate's Office Building Commission.

As Johnston explained repeatedly yesterday, the Hart building wasn't his idea - and the runaway cost escalation began long before he took the chairmanship a few months ago.

He argued that were it not for his removal of $37 million of "extras" - the gymnasium, plush carpeting, wall paneling and other accouterments - the Capitol architect's newest cost estimate would be $174 million.

Actually, the Appropriations Committee on Tuesday partially overruled Johnston's cuts, restoring the rooftop restaurant, the wood paneling and a large television studio-hearing room.

To bail out now, Johnston told the Senate, would leave a steel framework - "a $70 million monument to nothing other than the imbecility of the Senate, while 1,700 employes languish in inadequate quarters."

The only question, he said, given the general belief that the nine-story building will someday be completed - not withstanding yesterday - was this:

"Do you do it now or let the cost to the American taxpayer go up $700,000 for every month of delay?"

To mothballs advocates John H. Chafee (R-R.I.) and John C. Danforth (R-Mo.) the answer was plain: Stop work, seal it off and leave it as a symbol that the Senate finally learned how to say "no" to extravagance.

"Is it right to proceed with this and then tell the public to save and to cut inflation? For us to say you peasants out there must save, but not us?" Chafee asked.

"Let's say stop! Seal it in and then proceed with construction when our budget is balanced and inflation is stopped."

The appeal was powerful. Chafee and Danforth rounded up 45 allies, and a 47-47 tie killed Johnston's money amendment.

But a motion to reconsider the vote, offered by Robert Dole (R-Kans.), passed 49 to 47. A Chafee motion to table Dole's recount lost, 50 to 45. The final vote, approving the expenditure, was 49 to 46.

Phil Hart would have smiled. CAPTION: Picture, SEN. JOHN CHAFEE "...peasants must save, but not us?"