Leading House-Senate budget conferees yesterday neared agreement on a compromise that would raise taxes $12 billion next year, while cutting President Reagan's military buildup by half and allowing room for some new recession relief programs proposed by the Democratic-controlled House.

Conferees said the proposal would produce a fiscal 1984 deficit of roughly $170 billion to $180 billion, depending on how much, if any, of the money proposed for anti-recession programs is authorized and appropriated.

While many details remained to be worked out and no firm deals had been cut, sources said that key negotiators for both sides were close to agreement on principal elements of the plan and were testing sentiment for it in the House and Senate and among outside groups, ranging from the White House to organized labor.

Several House members said initial soundings indicated that the plan could pass in the House.

"It is a concept that looks salable over here," said Rep. Les Aspin (D-Wis.), a House budget conferee.

Senate Majority Leader Howard H. Baker Jr. (R-Tenn.) said the plan received a "pretty favorable reaction" from a group of leading Senate Republicans.

However, some senators also wanted to run the plan by Reagan, apparently out of concern that the White House, which sharply criticized the Senate's original budget as well as the budget approved by the House, would find fault with the compromise.

"I don't think anyone wants to be cut off at the knees after what's happened so far around here," said an aide to a Republican senator who attended the session.

As explained by several House and Senate members, the plan calls for revenue increases totaling $70 billion to $80 billion over the next three years, with more than $40 billion of the total coming in fiscal 1986, the third year.

Reagan had called for a standby tax increase of about $50 billion for 1986 but has remained adamantly opposed to anything more than nominal revenue increases in 1984 and 1985.

The proposed tax compromise for next year is considerably closer to the Senate's proposal of $9 billion than to the House figure of $30 billion, largely because of fears that a large tax increase next year would doom chances of a budget compromise in the Republican-controlled Senate.

On domestic spending, the plan includes a so-called "contingency fund" for $6 billion to $8 billion worth of new recession relief programs proposed by House Democrats, such as jobs creation and relief from home and farm foreclosures.

The money would be included in the budget, as Democratic liberals have demanded, but could not be spent unless the specific programs have been authorized, thereby assuaging conservatives' fears that the money might wind up being spent for other domestic programs.

Differences remain over other aspects of domestic spending, sources said, and some suggested that these could present obstacles to a final agreement, even though the disparity in dollars might be relatively small.

On defense, the conference leaders reportedly agreed in "concept," as one put it, on a 5-percent increase in military spending after accounting for inflation, which would be half the 10-percent after-inflation increase that Reagan has sought.

But the conferees have not agreed on the precise dollar amounts that would go into calculating a 5-percent increase. Senate conferees appeared to be interpreting 5 percent to mean an increase close to the dollar amount that the Senate recommended, but House members were insisting on something closer to a split-the-difference number.

About $2 billion is at stake in the dispute, said one House conferee, indicating that the difference is critical to both sides.

Because of the differences that remain over precise numbers, conferees were reluctant to predict yesterday that the proposed compromise guaranteed a conference accord that could pass both houses. But they said the chances had improved considerably.

"We're certainly better than 50-50 now," said Sen. Slade Gorton (R-Wash.), a Senate conferee. Speaking of House Budget Committee Chairman James R. Jones (D-Okla.) and Senate Budget Committee Chairman Pete V. Domenici (R-N.M.), Gorton added: "The problem is that neither Jones nor Domenici can sign a conference resolution that won't be passed by their houses."

The deficit anticipated by the proposed compromise would be considerably less than the $200 billion deficit for next year that Congress contemplated as it began its budget deliberations, although it would still be extremely high by historical standards. It is less than Reagan's budget anticipated but is roughly in line with the deficits in the versions approved earlier by the House and Senate.

No specific type of tax increase is contemplated in the proposal. Although the House is considering an income limitation on the 10 percent cut in the income tax rate scheduled for next month, senators have been adamant that their tax proposals are not aimed at whittling back Reagan's tax-cut program.