The Supreme Court yesterday agreed to consider whether federal immigration agents may interrogate a factory work force in search of illegal aliens.

The technique, called the "factory survey," resulted in apprehension of more than 20,000 illegal aliens in Los Angeles in one year before a federal appeals court ruled the practice unconstitutional last year, prompting the appeal to the Supreme Court.

The appeals court said the practice was an "unconstrained" form of mass detention and questioning not permitted under constitutional search and seizure safeguards.

Immigration and Naturalization Service agents have used the survey method in plants, particularly garment factories in California, which are believed to employ large numbers of illegal aliens. Armed with a warrant, or with consent of factory owners, agents walk through the plants asking about the immigration status of the workers.

Other agents guard exits to discourage escape attempts. Workers who identify themselves as aliens are arrested if they cannot produce immigration papers.

The results were dramatic at the two Los Angeles factories involved in yesterday's case. Two 1977 surveys at Davis Pleating produced 117 illegal aliens out of 500 employes. A survey at Mr. Pleat, another garment factory, resulted in 45 arrests in a work force of 90, according to the government.

Workers at those plants who were questioned but not arrested challenged the practice as a violation of the Fourth Amendment's protection from unreasonable searches. The 9th U.S. Circuit Court of Appeals ruled that only workers suspected of being illegal aliens could be questioned. The justices are expected to rule next year in INS vs. Delgado.

In other action yesterday:

* The justices, in a Virginia case, agreed to decide whether judges and magistrates can be ordered to pay legal fees of plaintiffs who prevail on constitutional challenges to their judicial actions.

The case stemmed from a successful civil rights suit against Culpeper County Magistrate Gladys Pulliam attacking the pretrial jailing of defendants who cannot make bail upon being charged with minor offenses that carry no jail term. Losing defendants in civil rights suits are often ordered to pay legal fees for the winning party. Judges and magistrates are immune from damages suits, however. The question in yesterday's case, Pulliam vs. Allen, is whether they should also be immune from legal fee awards.

* The court entered a controversy over standards used by appeals courts in reviewing lower court libel judgments. The case, Bose Corp. vs. Consumers Union, was started by a stereo manufacturer who objected to negative comments about his speakers that appeared in Consumer Reports magazine.

The Bose Corp. won $210,905 in damages and legal fees from the magazine in U.S. District Court. But the 1st U.S. Circuit Court of Appeals overturned the judgment, rejecting the finding that the magazine acted with "malice," a requirement in libel judgments involving public figures.

Bose's appeal to the justices contended that the appeals court improperly reviewed the factual findings of the lower court, bending over backward because of the free speech issues involved in libel cases.

* The court said it would consider a lower court decision telling the Social Security Administration to speed up its appeals process for those seeking disability benefits and requiring the government to pay interim benefits during delays that exceed 90 days.

Disability benefits are paid to those who are unable to work because of physical or mental impairment. The case, Secretary of Health and Human Services vs. Leon S. Day, could affect more than 2 million people who apply each year for the benefits.