The District government has agreed to spend an estimated $3 million on new cells, security equipment and health improvements at the Lorton Reformatory medium security facility, a sprawling complex of buildings that house more than 1,300 men convicted of serious crimes.

The expenditures, outlined in papers submitted to U.S. District Judge June L. Green yesterday, are part of a proposed settlement of a massive, class-action lawsuit filed against the city by inmates who complained of unchecked violence, overcrowding and unhealthy living conditions there.

As part of the agreement, the District also will spend an estimated $1.5 million annually to increase the number of guards at the facility 18 miles south of Washington in rural Virginia and pay for staff at a screening center at D.C. Jail where newly sentenced defendants will be evaluated before they are transferred to Lorton to serve their terms.

Attorneys yesterday described the new "receiving and diagnostic center" as a sophisticated step toward identifying the needs of new inmates, from housing preferences to reading levels and vocational skills. That knowledge, they said, can be used to improve the quality of prisoners' lives and their prospects for rehabilitation.

Peter J. Nickles, an attorney for the Lorton inmates, said yesterday he is hopeful the security measures in the settlement agreement, which is expected to be made final in 45 days, would help eliminate inmates' "fear for their own lives."

Environmental improvements, inmate screening and new training programs should provide a "structured environment to work in" and help combat the atmosphere of idleness that plagues most penal institutions, Nickles said.

The Lorton inmates were represented at no cost by Nickles and other lawyers from the firm of Covington & Burling. In June 1980, the same lawyers won a $600,000 jury award for 400 inmates at Lorton's maximum security facility. Those inmates contended that conditions for them violated constitutional protections against cruel and unusual punishment. The case is now in the U.S. Court of Appeals.

Two months after that decision, Nickles filed the lawsuit for the medium security inmates, which led to the "Agreement of Principles" submitted to Judge Green yesterday for approval.

The case had been scheduled to go to trial today. Instead, Green received the proposed settlement agreement and copies were to be circulated at Lorton last night. The trial has been postponed, pending the final agreement.

Like the maximum security inmates, the prisoners in medium security say they primarily are concerned over internal violence, which their lawsuit blamed on a shortage of guards, inmates' unrestricted access to weapons and overcrowding. The lawsuit also alleged that inmates are allowed to roam the facility unsupervised, which they see as a threat to internal security. Alcohol and drugs are prevalent, the lawsuit said, the food "wretched" and the living conditions unsanitary.

As part of the proposed settlement agreement, a total of 106 new individual cells will be constructed. Twenty-six new isolation cells will be added to the 20 already in use at the central facility to segregate selected inmates from the general dormitory population, either for disciplinary reasons or for their own safety. Eighty new cells will be built in a closed-down furniture repair shop.

The new cells will also be used for inmates who could not be housed in the nearby maximum security facility because of overcrowding. Medium security inmates had complained that the more violence-prone maximum security prisoners were being routinely assigned to their facility, generating security risks.

The District also has committed itself to buy additional walk-through metal detectors and hand-held equipment to frisk persons moving in and around the facility. The city will also install an intercom system that will give inmates a means to alert the guard control center of trouble within the institution. New lighting also will be installed on the facility grounds, the proposed agreement said.

Attorneys on both sides of the case also have agreed to monitor the growth in the inmate population and to agree on an acceptable population ceiling. If the number is exceeded, the proposed settlement agreement says that the judge could designate an officer of the court -- known as a "special master" -- to consider ways to reduce the population.