The Federal Election Commission yesterday agreed to exempt the Socialist Workers Party from listing the names of contributors on campaign finance reports on grounds that the donors might be subject to harassment.

A consent decree approved by a three-judge panel at the U.S. District Court here said evidence presented by the party demonstrated such harassment "from either government officials or private parties" had occurred in the past and that there was a reasonable chance it might again.

Under the decree, the party and its candidates will be required to keep the names of its contributors, but will not have to publicly disclose them as do candidates for other groups.

The agreement was considered a major victory for the SWP, a Trotskyite group, and the American Civil Liberties Union, which brought suit against the FEC in the party's behalf.

It's a complete vindication of the charges of harassment and spying that we have leveled against the FBI and other government agencies," said Jack Barnes, SWP national secretary. "The SWP believes the decision will strengthen our position in the ongoing fight against FBI spying."

Requiring controversial groups like the SWP to disclose its financial backers "serves absolutely no purpose yet has great potential for harm and mischief," said Ira Glasser, ACLU national director. "We are confident this judgment will serve as a model in similar cases now pending all over the country."

In a related case in New York, the SWP and an affiliate, the Young Socialists Alliance, are seeking $40 million in damages against the FBI. That suit has established that the FBI used some 1,300 informants in a surveillance program of the small radical political party between 1938 and 1976.

The party charges that the informants burglarized party offices and actively harassed its members, with the knowledge of the FBI.

Attorney General Griffin B. Bell was found in contempt last July after refusing to turn over confidential FBI files in the New York case. His appeal is still pending.

The suit against the FEC was first brought in 1974. Since that time, the SWP has maintained that federal election laws requiring the names, addresses and occupations of donors to political campaigns provide the government with "a ready-made enemies list."

A consent decree is a legally binding agreement made by both parties in a suit in which it is not necessary to admit past guilt. It then is approved by a judge, or in this case, a three-judge panel made up of U.S. Circuit Court Judge Edward A. Tamm, and U.S. District Court Judges Gerhard A. Gesell and John H. Pratt.

In this case, the order said the SWP had demonstrated that its members had been "subjected to systematic harassment" in the past and that there was a danger of "threats, harassment or reprisals from either government officials or private parties" in the future.

Under the order, which is in effect until 1984, the party is permitted to print the following on its campaign literature: "A federal court ruling allows us not to disclose the names of contributors in order to protect their First Amendment rights."