The tentative agreement reached by the United Auto Workers union and General Motors Corp. Sunday night is a textbook example of the politics of collective bargaining. Nobody lost.

The company left the bargaining table with a potential $2.5 billion in labor cost savings over a proposed 30-month period ending Sept. 14, 1984. The union left with its desperately needed job security provisions and a little bit extra, such as a prepaid legal services plan and a company agreement to set up and finance an internal occupational safety and health advisory board.

That is not a bad deal in an industry that has experienced a precipitous decline in sales and employment over the last two years.

The agreement closely resembles one the UAW signed with Ford Motor Co. on March 1, giving that company up to $1 billion in labor cost savings over a 31-month period. But from the union's viewpoint, the GM package has improvements, including:

* The scrapping of plans to close four plants.

* A prepaid legal services plan, under which the company will contribute 3 cents an hour per worker to an employes' legal fund. Legal representation would be provided by GM staff attorneys in wills, divorce proceedings, credit and consumer problems and misdemeanors.

* Guaranteed income for laid-off workers with 10 years' or more seniority, compared with 15 years' minimum seniority under the Ford plan;

* A profit-sharing plan based on stockholders' equity plus other assets. The Ford plan is based on a percentage of profits from total sales by its U.S. operations, excluding sales from Ford's aerospace and land development divisions.

* A pilot "lifetime" employment guarantee program at four GM plants compared with a similar program planned for two Ford facilities.

* A program to reduce chronic absenteeism, basically by reducing the nonwage benefits available for the chronic absentee.

* Improved worker discounts on the purchase of GM cars and trucks.

The union also won a two-year moratorium on plant closings, which allow the company to use outside contractors, foreign and domestic, to produce GM parts.

In return, the company received concessions that would:

* Freeze basic hourly wages for 30 months, the life of the contract.

* Reduce benefits for salaried workers through a "shared sacrifice" agreement with the union.

* Defer three cost-of-living increases for represented workers.

* Lower wages and benefits for new hires.

* Eliminate all paid personal holidays, such as birthdays, previously awarded UAW members.

* Eliminate the once-a-year December Sunday Bonus payment, which actually was another way of giving workers another paid holiday.