Attorney General Griffin B. Bell told a federal judge in Manhattan yesterday that he will not obey a court order to turn over files identifying confidential FBI informants who spied on the Socialist Workers Party.

In an affidavit to U.S. District Court Judge Thomas P. Griesa, Bell said he was willing to accept sanctions, including loss of the $40 million civil suit, to protect the names of informants.

Attorneys for the SWP told Griesa they will file motions asking that the federal officials he held in contempt of court for disobeying the order. Griesa has threatened just that action.

But Bell argued that a contempt citation is not warranted. "This is not a decision which FBI officials, any other government officials or I have made in a spirit of defiance of court orders or out of a contemptuous attitude toward this court or its authority," Bell said in the affidavit.

The Socialist Workers Party and an affiliated group, the Young Socialist Alliance, are suing the attorney general and several other high government officials, charging that starting in 1938 government investigators illegally burglarized party offices, blacklisted members, wiretapped conversations and committed other harassing acts. Attorneys for the two groups are seeking the files of FBI informants to help prove their case.

Terrence B. Adamson, Bell's spokesman, took pains yesterday to emphasize that the attorney general's decision was "not outside the law. Accepting sanctions is our only avenue to have the discovery order appealed."

The Supreme Court refused on Monday to review Griesa's order that the files he made available to SWP attorneys. The 2nd U.S. Circuits Court of Appeals had turned down the case earlier on technical grounds because Griesa's order was not the final judgment in the case and thus was not appealable.

In its brief to the Supreme Court, the Justice Department had argued that it would be "pointless" to force Bell to refuse Griesa because that "could lead only to confrontation between two branches of government."

"Moreover it would be unseemly for the chief law enforcement officer of the United States, sworn to uphold and obey the law, publicly to disobey a court as the price of obtaining review of ruling he believes to be both unsound and certain to harm the proper functioning of government," the brief said.

Bell said yesterday that he was willing to turn over only four of the 18 files mentioned in the discovery order because 14 informants would not give their permission to be identified.

Releasing the files "would have a significantly detrimental effect on law enforcement" by undermining the pledge of confidentiality that has been the "cornerstone" of FBI dealings with informants, Bell said.

He noted that the government has accepted sanctions "from time to time" to protect information it considered privileged.

Adamson later cited as an example a 1973 case in which then-Attorney General Elliot L. Richardson claimed executive priviledge in refusing to obey a discovery order.