The Senate Agriculture Committee worked a little magic yesterday, finding a way to slash $1.3 billion from federal farm-program spending this year without forcing farmers to feel the pain.

Threatened by across-the-board cuts unless Congress reduces total fiscal 1988 spending by $23 billion, the committee approved a package of changes that apparently would meet its target of $1.3 billion in reductions.

It wasn't easy, Chairman Patrick J. Leahy (D-Vt.) said, as he parried attempts by various members to tack on amendments that he warned would unravel a carefully crafted compromise.

"Farm income is protected. Our savings targets under the budget resolution are met. And, the operation of our existing farm programs will be improved," Leahy said.

No members challenged Leahy's arithmetic, but his package -- similar to a counterpart budget-reduction measure passed by House Agriculture last week -- featured several provisions that appeared to save more on paper than in reality.

One, forecasting savings of more than $800 million, would allow the agriculture secretary to increase the amount of land he could require farmers to idle without paying them subsidies if wheat and corn stocks are projected to exceed certain trigger levels.

Based on January data that the committee was required to follow, stocks were projected to exceed the triggers. But August data, which is disregarded in the budget process, showed that stocks did not reach anticipated levels. Result: the committee could claim the savings.

Another big saver, worth $75 million in the calculations, would be Leahy's changes in the dairy program. Dairy farmers would be spared part of a price-support reduction expected in January if they contributed to a promotion fund to spur milk sales.

Under this plan, the guaranteed government support price would fall only 20 cents in January, instead of the scheduled 50 cents, if surplus purchases are projected to exceed 5 billion pounds next year. If surplus purchases continued at that rate, the support again would fall by 25 cents in July.

Sen. Rudy Boschwitz (R-Minn.) worried that dairy producers would lose about 83 cents per hundredweight of milk if the budget-cut package fails and the administration makes across-the-board reductions. He sought protective backup language.

"I appreciate the anxieties, but this is unfair on the face of it," said Sen. Richard G. Lugar (R-Ind.), who supported the package without amendments. Leahy assured Boschwitz that the dairy concerns were being addressed elsewhere on Capitol Hill.

The committee, in another bow to the dairy industry, found an additional $13 million saving in packaged frozen pizza. The panel voted to require that frozen meat pizza be clearly labeled as to whether contains imitation cheese.

The change has been pushed for months by the dairy lobby, which argued that once consumers learned their frozen pizzas contained fake cheese, they would switch to brands made with real cheese. The sale of more real cheese would cut government surplus purchases and save more than $50 million in three years.