Chancellor Helmut Schmidt's government has managed to pull back from the edge of collapse following agreement between the two West German coalition parties on the outlines of a 1983 budget.

A compromise on the budget plan had been regarded as a key test for the ability of the shaky coalition to carry on. The agreement--reached last night after a long day of wrangling and an 11th-hour compromise proposal put forward by Schmidt--is expected to quiet speculation about a breakup of the government before the next general elections in 1984.

Such speculation has surrounded Bonn's left-center coalition for more than a year as a result of growing left-wing resistance in Schmidt's Social Democratic Party to compromises with the more centrist Free Democrats, and mounting reluctance among the Free Democrats to remain partners with the decreasingly popular Social Democrats.

The budget agreement was formally approved by the Cabinet today. Editorials in leading conservative papers contended that the country had missed an opportune turning point and would now have to put up with two more years of weary, strained coalition rule.

Schmidt told reporters he was very satisfied with the outcome. Contrary to a widespread sense of heightened tension about the coalition's fate in recent days, Schmidt indicated that he had never expected the government to fall. A non-German source, known to see the chancellor with some frequency, described Schmidt as appearing in private recently "more at peace with himself than I've ever seen him."

Asked how close he thought the coalition had come to splitting up, Schmidt replied: "About as close as the exchange rate of the dollar is to its real value."

The answer reflected the West German leader's longstanding concern that high U.S. interest rates, which he has started linking in public criticism to large U.S. deficits, have pushed up the international value of the dollar at the expense of West European currencies and economies.

Taking another critical shot today at U.S. economic policy, Schmidt noted that since 1978, America's budget deficit had nearly quadrupled while the West German deficit had grown by about 20 percent.

At the same time, the chancellor said his country could no longer afford large increases in social spending.

The budget accord required Schmidt's Social Democrats to concede some cuts in social benefits, while the Free Democrats agreed to part with some tax advantages. On the benefit side, the cost of unemployment insurance here will go up next year and old-age pensioners will have to start paying for health insurance. On the tax side, multinational firms will be restricted from applying overseas losses to offset some profits. Richer married couples will get less tax relief.

The overall aim is to hold net federal spending to $11.4 billion, compared with $13.6 billion this year. This target falls nearly midway between the higher limit sought by the Social Democrats and the lower one proposed by the Free Democrats.

Differences in economic approach between the two governing parties have become sharper and more contentious since the economy dipped into a recession two years ago under the strain of higher oil prices, more competition in export markets and high interest rates.

Disputes over the national budget last year caused Hans-Dietrich Genscher, the foreign minister and leader of the small Free Democratic Party, to consider swinging his party into an alliance--and new government--with the conservative Christian Democrats. By forgoing a similar opportunity to change sides this time, Genscher is seen by many political observers here as losing any foreseeable chance of switching before 1984.