It was long past the senatorial bedtime - Thursday midnight - but the Senate was still at work, voting on whether to kill an amendment offered by Howard M. Metzebaum (D-Ohio) which he said would save the American consumer billions of dollars by holding down price supports for sugar.

A roll call was in progress. Warren G. Magnuson (D-Wash.), 73, chairman of the Appropriations Committee, went to the back of the senate chamber, raised his hand and called out, "Mr. President," seeking recognition to cast his vote. Magnuson looked tired, as befit the hour.

The clerk called out in return, "Mr. Magnuson."

"No," Magnuson said in a clear voice. It was a vote not to kill the Metzenbaum amendment - a vote against the position of Magnuson's senior colleague in the Senate leadership, who wanted the amendment killed so a higher price support could be paid the nation's sugar producers.

The reaction to Magnuson's "no" was instantaneous. Russell B. Long (D-La.), manager of the sugar bill and chairman of the Finance Committee, snapped his fingers at the senator from Washington state, and ran up the aisle toward him. Henry M. Jackson, Magnuson's democratic colleague from Washington, whispered loudly, "Maggie." Long reached him first and began whispering in his ear. Magnuson listened for a moment and said in a loud voice, "Oh." Then he raised his hand again and said, "Mr. President."

"Mr. Magnuson," the clerk replied. "Aye," he said, more firmly than the previous "No."

Even the smattering of tourists in the gallery realized what had happened, and laughter swept through the chamber. Long could not restrain a big grin as he walked back down the aisle. Magnuson retreated from the floor through swinging doors.

The end of the session - a legendary time on the congressional calendar - when debates that might ordinarily fill days or weeks are disposed of in moments and new laws sneak through the normal defenses of the House and Senate the way O.J. Simpson slips through airport crowds on the way to his rental car. Exhaustion competes - often sucessfully - with traditional congressional sobriety, and the gossip in the halls is all about when it will end.

The leadership promises late tonight - or early tomorrow - but those who watched or took part in the end-of-season circus last night and the night before questioned how that deadline can still be met.

Whether it is will depend largely on the uniquitous Sen. Long, who seemed to be in the middle of everything in the rush to adjourn. Many of his colleagues - not just Magnuson - looked the worse for wear when Long brought up that sugar bill late Thrusday, but the son of Kingfish looked fresh as a morning egg.

Another item Long must usher through the Senate is the modest package of energy taxes that House and Senate conferees adopted as companions to the president's "energy program." But his biggest job by far is the huge and complicated tax reduction bill.

As usual, the House the the Senate passed widely differing tax cut bills. As usual the House's was more modest and more carefully drafted. As usual the Senate bill includes lots of special amendments that Chairman Long fully expects to trade off in his conference with the House Ways and Means Committee.

Yesterday afternoon the staff of the tax-writing committees were working like beavers to conclude their paperwork and the members - or some of them - were meeting among themselves to discuss possible compromises.

But for more than half an hour yesterday afternoon. Long sat chummily with his pal. Herman Talmadge (D-Ga.) on the Senate floor, toying with an unlit cigar and chewing the fat. Or maybe discussing the tax bill - Talmadge is on the Finance Committee, too.

The end-of-session rusn provides opportunities for the venting of emetions that might be held in check during more sedate times. That was obvious late Thursday night in the House, when the topic for debate was the $7 billion foreign aid appropriations bill.

It was almost precisely what President Carter wanted in a foreign aid bill, and it passed the House earlier with little difficulty. Now it was back as a final conference report, all differences with the Senate having been resolved.

But House members still angry over Carter's vote of the much-beloved public works bill decided unexpectedly that the foreign aid measure might be a vehicle to bear the brunt of their frustration. Rep. John Rousselot (R-Calif.), an ultra-conservative, threw the president's words back at him, calling the aid bill "foreign pork."

Others decided the water projects for foreign countries in the bill. What made them better than the public works projects for members' home districts that the president insisted were unneded and inflationary? The anger seemed infectious, and when a motion was made to kill the bill, the vote was dramatically close.

House members follow their votes on an electronic scoreboard, and soon realized that this one would be tight. Republican members began cheering as the "Nay" column grew. At the end of the time alloted for voting the tally was close, and members clogged the well of the House to change their voters. Rep. Carl Perkins (D-Ky.), who lost a big dam in Yatesville, Ky., to Carter's veto, changed his veto for to against the bill, to applause from several Republicans. But House leaders and administration lobbyists prevailed on enough others to switch the other way, and the bill was saved 201 to 191.

One subject the Senate - or many of its members - did not want to debate was the question of how the Senate should guarantee fair treatment of its employes. Sen. Edward Brooke (R-Mass.), tried to introduce a resolution establishing an office and board to assure fair hiring and promotion practices, setting off hours of debate Wednesday night but no action.

Brooke and a number of other liberal senators said it was hypocritical for the Senate to exempt itself (as it has) from the fair employment standards it has voted for private industry and the executive branch. Others argued that this was proper and just, since the role of a senator - and his or her relationship with staff - is unique.

Sen. Robert C. Byrd (D-W.Va.), the wily majority leader, tried to coach his opposition to the Brooke proposal in procedural robes. He was for the idea, he suggested, but would have to oppose the procedure Brooke used to bring it to the floor (admittedly a controversial one).

Sen. Dick Clark (D-Iowa) jumped to his feet to ask, then, if Byrd would seek a unanimous consent agreement among senators to bring up the fair employment resolution in the normal way. "No," said Byrd, "I don't propose to get one right now."

End of session or not, it is widely felt in the Capitol that Byrd wants to spare his colleagues the embarrassment of having to vote on this question, which has been pending since May.