The chairmen of the House and Senate tax-writing committees agreed yesterday on several major aspects of a possible compromise tax cut plan, but remained divided on how many years the cut should run and how much to target it toward low- and middle-incomme taxpayers.

The two legislators, Rep. Dan Rostenkowski (D-Ill.) of the House Ways and Means Committee and Sen. Robert J. Dole (R-Kan.) of the Senate Finance Committee, while cautious about what has yet to be resolved, said they believed that they had made enough progress to discuss their plan with the administration and other leading Democrats.

Rostenkowski briefed House Speaker Thomas P. O'Neill Jr. (D-Mass.) late yesterday and will meet this morning with Dole and Treasury Secretary Donald T. Regan. Democrats on the House Ways and Means Committee are scheduled to caucus this afternoon.

Sources said the "consensus" proposal, which still must be approved by both the White House and other panel members, would involve a multiyear across-the-board cut in tax rates, as Reagan is seeking, but the crucial questions of how long and how deep the cuts will be are yet to be worked out.

The administration has been pushing for a 30 percent cut over three years, which it says is needed to spur savings and investment. But Democrats so far have opposed such a bill as inflationary and skewed too much toward high-income taxpayers.

Dole yesterday proposed paring that to a 25 percent cut over three years, beginning with a 5 percent rate reduction this Oct. 1, followed by 10 percent rate cuts in July 1982 and July 1983. Rostenkowski was said to be considering the plan, but has not yet embraced it.

Yesterday marked the first time that Rostenkowski has hinted publicly he would consider enacting a measure that would provide for tax cuts beyond just a single year. Previously, he had flatly opposed such a "multiyear" cut on grounds it could add to inflation. h

Yesterday, the House Ways and Means chairman told reporters that while both he and his panel still were opposed to Reagan's full three-year "Kempt-Roth" tax cut plan, "that doesn't mean that there isn't sentiment for a 30-month tax cut." He said "anything short of 30 months isn't Kempt-Roth."

Rostenkowski told a news conference after yesterday's meeting that "Sen. Dole and I are pretty much on target. I'd say there's more agreed upon than disagreed."

Dole also was optimistic. "We feel we are close enough that we ought to discuss it with the administration," he said. "If it were left to us, we think we could reach agreement."

Although both men declined to comment on the contents of any such package, sources speculated it probably would include such elements as a reduction in the marriage penalty, a cut in the maximum tax rate on investment income to 50 percent from 70 percent now, a cut in estate and gift taxes and increased tax incentives for retirement savings.

The compromise, if accepted by all sides, would mark a major break-through in congressional consideration of Reagan's plan. Dole said after the meeting that with the compromise in hand markup could begin as early as next week, with the tax bill enacted "in 30 to 45 days instead of five months."

He also said the Finance Committee would agree to draft its owns version of the bill at the same time as Ways and Means, abandoning its traditional practice of waiting, then loading up the bill with members' pet amendments -- a prospect feared by many Ways and Means Democrats.

"That would make it easier for us," Rostenkowski agreed.

The Kempt-Roth plan is named for the original drafters of the three-year proposal, Rep. Jack Kemp (R-N.Y.) and Sen. William V. Roth (R-Del.). Reagan embraced their measure during the 1980 presidential campaign and has modified it slightly since.

Congressionall sources speculated yesterday that prospects were good the Reagan administration would accept the new proposal. Treasury Secretary Regan and other officials have been negotiating privately with Dole and Rostenkowski for the past several days.

However, it was not immediately clear how Rostenkowski would fare with his own colleagues, either in the House leadership or among Democrats on the Ways and Means Committee. Speaker O'Neill has been pushing for a bill skewed more toward low- and middle-income workers.

Several hours before yesterday's meeting, Dole heightened the pressure on Rostenkowski by warning that if the two didn't reach an agreement by the end of this week, Republicans would employ a pincer move: The Finance Committee would begin drafting its own bill, while Regan would rally southern Democrats.

It was the defection of House southerners that gave Reagan his first stunning victory on the budget three weeks ago. Although Dixie Democrats have insisted publicly they want to remain within the party's fold this time, some have been talking privately with the White House.

The package discussed yesterday presumably would preserve the essential elements of Reagan's proposal, but would trim back the first year's tax reduction to help hold down the budget deficit in fiscal 1982. Fears of a large deficit that year have been making the financial markets jittery.

However, Dole conceded at a breakfast meeting with reports yesterday that his own version of the proposal -- a 25 percent cut in tax rates over three years plus the other provisions favored by Democrats -- actually would cost more than Reagan's original package in 1984 and later.

If the proposal were accepted, the administration presumably would drop its insistence on deferring the Democrats' provisions until a second tax bill, which the administration has promised to send up in August. Many lawmakers have been fearful that Congress wouldn't have time this year to take up a second bill.