On occasion lately, President Reagan has appeared to be at war with himself.

His promise to get tough with the Soviets has clashed head-on with his commitment to corn and wheat farmers to keep the door open for them to sell grain to the Soviet Union.

His desire to spend billions to rebuild America's defenses has run into conflict with his goal of reducing federal deficits and balancing the budget.

In Hartford, Conn., last week, he described cutting taxes--last year he cut taxes by $350 billion--as essential to preserve an "economic freedom" that is linked to political and personal freedoms. Meanwhile, in Washington, he was pushing for the largest tax increase in history.

These inconsistencies can easily be exaggerated. Nevertheless, administration decision-makers have expressed concern about the internal contradictions of some of his recent decisions.

They are anxious to avoid the traps of flip-flopping on issues or becoming immobilized in the consideration of available options, which they feel so severely damaged Jimmy Carter and was a successful campaign issue for Reagan.

But Reagan's problem appears to be less one of choosing among options as much as in finding maneuvering room between his absolutist philosophy and the nettlesome intrusion of events and political necessity.

Last month the Cabinet, National Security Council and then top presidential advisers and key Cabinet officers debated what he should do about grain sales to the Soviet Union.

But, whipsawed by the need to honor his commitment to get tough with the Soviets and to keep his campaign promise to farmers that he would not restrict their exports to the Soviet Union as Carter had done, Reagan had decided before any of these discussions that the only acceptable option was a one-year extension of the existing agreement he eventually announced.

"The only argument on grain was how the decision should be postured publicly," an administration official said.

His grain compromise did not go down any easier because it contradicted his adamant attempt to punish the Soviets for their policies in Poland and Afghanistan by trying to thwart western European participation in construction of the Soviet natural gas pipeline.

On defense spending, Reagan split the difference between the opposing views of his principal advisers when he decided that while he would accept reductions in spending next year for his military buildup, he did not feel bound by the cuts for fiscal years 1984 and 1985 in the budget compromise with Congress.

The appearance of contradictions is the result of real differences among Reagan's senior aides and key Cabinet officers on the making and implementing of policy.

The major division, according to one administration friend, is between those around Reagan who want him to adapt to the realities of Washington and his ideological soul mates who want Washington to adapt to him.

Defense Secretary Caspar W. Weinberger and national security adviser William P. Clark are among those who pressed Reagan to stay NEWS ANALYSIS with his original proposals for higher defense spending and to take a hard line with the Soviets on the grain issue.

On the other side were White House chief of staff James A. Baker III, Treasury Secretary Donald T. Regan and Office of Management and Budget Director David A. Stockman, pressing Reagan to adjust his objectives to the political considerations on Capitol Hill, among farmers and among our European allies.

The apparent fraying of policy comes as the White House attempts to hold together in an election season what one friend describes as the "inherently contradictory" coalition that elected Reagan.

The president and his aides are facing an open revolt against the tax bill by core "New Right" Reagan supporters, a tense, difficult crisis in the Middle East and a deepening recession that was not foreseen.

More and more, the White House is having to grapple with the intrusion of reality on theory.

"For the first time, they're beginning to realize to what degree events dominate the best-laid plans of mice and men," said Rep. Newt Gingrich (R-Ga.), a supply-sider and early philosophical supporter of Reagan, who has enthusiastically joined the conservative revolt against Reagan's tax increase.

Reagan's critics, such as House Speaker Thomas P. (Tip) O'Neill Jr. (D-Mass.), last week were renewing their argument that there always was an inherent contradiction in the president's goals of cutting taxes, increasing defense spending and balancing the budget.

Believers like Gingrich argued, on the other hand, that the program would eventually work and praised Reagan for the degree to which he has already reshaped the national agenda to his conservative goals.

But, there is concern within this administration, which has been adroit in bending Congress to its will and winning public support, about its comparatively weak policy-formulating apparatus.

The grain decision, for example, left virtually no one happy.

"That's the way compromises are," one administration official said last week.

The farmers were displeased, arguing that the uncertainty resulting from the failure to negotiate a long-term agreement complicates their planning and aggravates problems of oversupply and getting credit.

It further inflamed the European allies over Reagan's efforts to prevent them from selling technology and equipment for a Soviet natural gas pipeline to western Europe. Administration officials acknowledge that there is little acceptance there of Reagan's argument that the pipeline gives the Soviets western techonology and capital while grain sales take hard cash from the Soviet economy.

It is doubtful how much of a sanction against the Soviets the one-year grain sales extension is, especially after Reagan virtually promised Iowa farmers last week that he had all but ruled out any future restrictions in corn and wheat exports.

In deciding on defense expenditures, Reagan found a middle ground between the opposing views of his advisers.

Weinberger, backed by Clark, had argued for bringing defense expenditures back to the levels Reagan originally requested in the budgets for the fiscal years 1983, 1984 and 1985, despite his compromise commitment with Congress to accept reductions.

Baker and Stockman were concerned that this would appear to be reneging on the compromise and anger Congress, as in fact it did.

Reagan decided to honor the reductions for fiscal year 1983 but agreed to permit the Pentagon to begin planning budgets for 1984 and 1985 at the originally requested higher levels, although he did agree to "review" the figures before next year's budget is sent to Capitol Hill.

Reagan's compromise was a temporary cease-fire; later this year and early next year, as the administration completes the 1984 budget that is to be sent up to Capitol Hill, the fighting will resume.