Buffeted by eight months of setbacks in Congress, President Reagan appears to have shifted his legislative strategy toward compromise and accommodation on such difficult issues as trade and South Africa to pave the way for favorable action on his tax revision initiative.

White House officials said chief of staff Donald T. Regan has abandoned the confrontational approach that he had taken earlier this year, and in recent weeks plunged into a round of private consultations with congressional leaders.

Officials said Regan's new approach has begun to narrow the differences between the president and his Republican allies in Congress over priorities for the rest of this year.

Only last month, White House officials were predicting that Reagan would pursue a "veto strategy" this fall on issues ranging from trade to spending to South Africa.

While some vetos are still likely, officials said the new effort at accommodation was motivated in part by a desire to avoid almost certain defeat on key issues at the outset of what the White House has described as Reagan's "fall offensive."

The officals "realized they are up against a brick wall and are just not going to win," one official said.

Another reason for the new approach, officials said, was to try to preserve Reagan's political strength at home before his November summit meeting with Soviet leader Mikhail Gorbachev.

The new attitude was demonstrated twice last week as Reagan moved to head off a veto confrontation with Congress over economic sanctions against South Africa and the White House decided to work with Republican lawmakers to write a trade bill in the face of growing bipartisan demands for protectionist legislation.

Several officials said their goal is to bargain with Congress over the nettlesome issues so as to leave the president in the best possible position to push for enactment of his tax overhaul plan by year's end.

"I think the administration is becoming more practical and flexible," said Sen. John Heinz (R-Pa.), chairman of the National Republican Senatorial Committee and an influential lawmaker on the trade issue. "Perhaps this signals the coming of political age for Don Regan."

"There is a growing realization" at the White House, he added, "that many of the issues the administration has had on the back burner or didn't know were cooking in the kitchen -- like trade -- will not go away. Trade has heated up to such a temperature that failure of the administration to work with Republicans and concerned Democrats on it will not only have electoral consequences but it will jeopardize tax reform as well."

Lingering doubts about the new approach are still heard frequently in the Republican-controlled Senate, where there has been deep resentment over the summer's conflict on the budget. Although Majority Leader Robert J. Dole (R-Kan.) was working with the White House last week, he predicted that the Senate may demand more than Reagan is willing to give, such as import relief for the textile industry.

Even the combined forces of the White House and Dole could not keep 12 Senate Republicans -- half of them up for reelection next year -- from defecting on the first South Africa sanctions vote.

"I wouldn't overplay that there's been a great new rapprochement,"said Sen. John H. Chafee (R-R.I.), chairman of the Senate Republican Policy Committee.

"They came to our view on South Africa because clearly the parade was getting out ahead of them," Chafee said. "On trade, again the steam had built up and they had to do something." He added that the White House overtures on trade and South Africa "are getting people back together, but clearly the train was getting ready to leave the station anyway."

Roger Stone, a Republican political strategist, said the stakes for Reagan are high in terms of controlling the agenda and preserving his high public approval rating.

"Reagan was an activist president in his first term. He cannot afford in his second to be a stand-pat political figure," Stone said. "He can't just say, 'I'm a free trader, and that's the end to the trade problem.' He can't appear intransigent on South Africa. The president has great political strengths, and as long as he remains on the activist side of the debate, I think he will win."

Although Reagan compromised on the South Africa sanctions and has sent conciliatory signals on trade, a host of other issues will test the White House in the weeks ahead. Among them are the farm bill, raising the debt ceiling to the $2 trillion mark and the threat of spending bills larger than administration targets.

Officials said Reagan is still prepared for selected vetoes, but wants to choose his targets carefully.

Within the White House, Regan is considered the central figure in the shift in strategy. Earlier this year, he had taken a highly visible and confrontational approach to Congress, at one point pounding the podium during a speech, demanding that Congress act on the budget.

Regan had antagonized first House Republicans and then Senate Republicans with a series of agreements to trim Social Security inflation adjustments. Dole had warned that election-bound senators would be increasingly independent.

As the president headed for his California vacation in August, Regan and his staff started planning in Santa Barbara for a "fall offensive" on trade, spending, the farm bill and the debt ceiling. At the time, they said Reagan would take an aggressive stand against pressure for new spending, in part because the congressional budget compromise had fallen short of expectations for reducing the deficit.

For example, the White House threatened to revert to the Senate budget proposal with lower domestic spending levels as a benchmark in some cases for vetoes, instead of the final congressional compromise. Presidential spokesman Larry Speakes also said Reagan considered the farm bill a prime candidate for a veto unless Congress held the line on its cost.

But the strategy shifted in the final days of Reagan's vacation and after his return to the White House. One top aide to chief of staff Regan said, "We decided to confront the problems instead of the people."

Officials said several of Regan's subordinates influenced him to take a different tack. Among them were Dennis Thomas, a former administration lobbyist and a leading deputy to the chief of staff, and outgoing political director Edward J. Rollins. These and other aides said that an early defeat for the president, such as a veto override on South Africa sanctions, could leave Reagan vulnerable for months.

In addition, officials said, Regan had a personal stake in wanting to show that he could successfully manage relations with Congress after eight months of difficulties. Regan first came to the White House saying he would attempt to run it like a chief executive officer of a corporation, letting others manage the details of handling Congress. This set Regan apart from his predecessor, James A. Baker III, now treasury secretary, who is regarded as a hands-on legislative tactician.

Reagan took the advice of his aides, and made a series of trips to Capitol Hill for closed meetings with lawmakers. "He's in his listening mode," said one lieutenant. "He's got a callous on his ear."

A House Republican leadership aide said Dole and House Minority Leader Robert H. Michel (R-Ill.) helped convince Regan to take the new approach. Regan, the aide noted, spent more time with Michel in the last two weeks than he had in all the previous time as chief of staff.

Rep. Dick Cheney (R-Wyo.), chairman of the House Republican Policy Committee, said Regan has made an effort to consult with House GOP members. "I think the White House has come around," he said.

As legislators came back from a month in their districts, they reported far more concern over trade issues and the deficit than over Reagan's tax revision plan, and the deteriorating situation in South Africa had only strengthened their views about economic sanctions.

For the White House, trade and South Africa were "like a gun pointed at their heads," a Republican congressional strategist said.

On South Africa, Reagan imposed his own sanctions to head off those Congress was threatening to enact. On trade, Reagan agreed at a White House meeting to work toward a single Republican bill to counter pressure for legislation to protect such industries as textiles and shoes from imports.

However, Reagan, in impromptu remarks, also told Republican congressional leaders that he remains strongly committed to the principle of free trade, and officials have said it is doubtful that a GOP trade bill would dampen pressure for restrictive measures.