Formal negotiations for an electoral alliance between the dominant French Socialist Party and the severly weakened Communist Party in France's forthcoming legislative elections opened here today with the Socialists setting the toughest conditions they have ever made.

The Socialists have demanded that the Communists not back the Soviet Union on key foreign policy issues and have said they must be prepared to go along with the government, rather than criticize it from the inside if they are to have Cabinet posts.

The talks between the two parties take place against the background of what Communists freely admit to be their greatest disarray in decades prompted by their party's loss in the recent presidential elections of a quarter of its traditional vote of about 20 percent.

The leadership and tactics of party cheif and presidential candidate Georges Marchais are contested openly in party circles. At a recent meeting of militants in the Paris worker suburb of Gentilly, Marchais is reliably reported to have said that after the legislative elections in June there would have to be an internal debate on responsibility for the party's decline and that he would accept discussion of his own leadership style.

Some veteran Communist Party workers say in private that they fear their party's decline and its reduction to a marginal factor in French politics may be irrevocable. If so, that would be the most important political change in France since World War II, when the party's resistance record gave it lasting prestige.

The main issue in the Socialist-Communist negotiations, but one that is unlikely to be settled until after the election results are in, is whether the Communists will get posts in the Cabinet formed after the voting.

The dominant view among top Socialists associated with President Francois Mitterand is that it is better to have the Communists in than out, where they could form the leftist opposition to the government and regain lost ground.

Mitterrand is a veteran of the pre-de Gaulle Forth Republic, when members of so-called Third Force governments like himself were prey to the devastating convergent opposition of the Communists from the left and the Gaullists from the right -- a situation that could easily be reproduced if the Communists so choose. The Gaullists and other center-right groups took advantage of Communist strength to try to entrench themselves in power permanently by using the Communist menace as the standard electoral argument against leftist victories. That was the significance of Gaullist novelist-adventurer Andre Malraux's famoust dictum: "Between us and the Communists, there is nothing."

The top Socialists are aware that the U.S. government would be likely to view Communists in the French government, even if they had only a few minor posts, with deep suspicion.

Moreover, the Socialists leaders have no ready answer to the argument likley to be made in Washington that, even if letting the Communists into the government might make sense in France, it would set a devastating example in Italy, Spain and Portugal -- the countries of southern Europe in which U.S. diplomacy had extended great quiet effort to keep the important Communist parties excluded from a share of power.

French External Minister Claude Cheysson, who is paying his first foreign call as minister to Washington next week, is known to want to explain the Mitterrand position on the Communists to the Americans. But he is understood to be under constraints against doing do in public because of the delicate electoral situation here.

French Socialists say privately that this is too great an opportunity to pass up since Communist weakness has never made them so docile. Mitterrand loyalists say that the most the Communists are likely to get is three or four relatively minor posts such as culture, youth and sports and transport after the voting June 14 and 21.

Socialist Party First Secretary Lionel Jospin publicly reiterated on Monday that the Communists must drop their support for Moscow on such key issues as Poland, Afghanistan and the Soviet SS20 missles aimed at Western Europe. He said the Communists also must accept ministerial solidarity -- meaning that they cannot both be in the government and free to criticize it.

Sources close to the Communist leadership said that, although the Communists and Socialist positions on a number of questions are fundamentally different, there should be no problem working out texts on most issues. The ony real problems are Afghanistan and the missles, they said. In private contacts with the Socialists before today's meeting at Socialist headquarters, the Communists say they presented conciliatory draft texts.

The other big issue is how many seats in parliament the Socialists in effect concede. The Communists are reliably said to have started out in informal talks by asking that the Socialists supposrt all 86 Communist incumbents in the 491-member National Assembly. The Socialists say they refused. Mitterrand was so far ahead of Marchais, even in traditionally Communist districts, that the Socialists are expected to take away about half the Communist seats.

Among the Communists threatened are several members of the Politburo, including Marchais deputy Charles Fiterman and Paul Laurent, regarded as the leader of the liberal Eurocommunist wing inside the Communist establishment. By the choice of strong candidates, the Socialists have already served notice in effect that they plan to extend no favors to Communist pro-Soviet hard-liners.

The Socialists do indicate willingness to make half a dozen or so "gifts" to Communists they approve of by withdrawing front-running Socialists to make room for some of the Communists in the second, runoff round of the elections. While there is ample historical precendent for such deals, for the Communist leaders to have to accept such favors now is bound to be seen as a humiliation.

Public opinion polls show the Communists slipping even lower than 15 percent in June, but most analysts assume that it can regain as much as half of its losses if it campaigns well, scoring perhaps 17 or 18 percent. Going aginst that view are the results of factory elections since the May 10 election, in which the dominant Communist-led General Labor Confederation had lost ground to the noncommunist unions.

It is considered likely that Marchais will be offfered as scapegoat. But, as a Socialist veteran of high-level dealings with the Communists said, "If they are too weak, they will need Georges too much to drop him."

Marchais and the group around him are challenged by the mutually conflicting oppositions of the liberals who opposed the Communist sabotage of the Socialist-Communist alliance that prevented a leftist legislative victory in 1978 and by the pro-Soviet hard-liners who opposed the electorally unproductive Marchais appeal to working-class racism.

Noncommunist intellectuals had turned Marchais, with his bluff, menacing manner, into a kind of media cult hero whose Archie Bunker image fascinated them. It apparently did not sit well with workers, however.

"Marchais is just too boorish, brutal and uncultivated for French workers," said Phillipe Robrieux, a leading former Communist historian who has just finished a respected two-volume party history.

"The kind of skilled worker who makes up the backbone of the party is bleeding himself white to send his kids to school so that they will escape having to go into the factory like he did," said the working-class Robrieux.

"A man like that doesn't speak very cultured French himself, but he resents the image Marchais projects of the workers when he speaks badly. That skilled worker wants his son to speak good French."