A major shakeup inside the Angolan government early this week appears to have strengthened the position of President Agostinho Neto, who has been warning in only slightly veiled terms of the need to safeguard Angola's independence from both the Soviet Union and Cuba.

Western diplomatic sources here have told visiting Sen. George McGovern that one reason for Neto'd firing of a top Cabinet minister last Saturday was that the minister had signed an agreement with Cuba, without the president's approval, to send another 6,000 civilian technicians to help bolster Angola's ailing economy.

This would bring the total number of Cuban civilian and military personnel in the country by the end of January to around 30,000.

President Neto has also been seeking an opening to restore diplomatic relations with the United States. Both the Nixon-Ford and Carter administrations have linked U.S. recognition to the reduction of Cuban troops stationed in Angolan, a precondition Neto has steadfastly refused to accept.

The economics minister, Carlos Rocha Dilolwa, lost his job as a deputy prime minister was abolished. He was also dismissed from the Politburo of the ruling Popular Movement for the Liberation of Angola (PMLA).

Dilolwa was head of the mixed Angolan-Cuban Commission and had just recently returned from a visit to Cuba during which he reportedly signed more than two dozen new accords providing for additional Cuban economic assistance.

Also dismissed from the 11-member MPLA Politburo was a longtime friend of Neto, Lopo do Nascimento, whose position as prime minister was also abolished.

Meanwhile, Western diplomats here are interpreting Neto's repeated references in a speech Sunday to the need to "defend the independence of the Party" as an almost certain reference to excessive Soviet and Cuban influence here.

At a rally marking the 22nd anniversary of the founding of the MPLA, the president said, "It is necessary at all times to defend the independence of the country."

While Neto never mentioned either the Soviet Union or Cuba by name, it is widely felt here that he could only be referring to these two countries as they are the most powerful outside influences on both the government and Party.

There has been a marked effort by President Neto in the past six months to improve his relations with the West, particularly with the United States. Washington has never recognized the MPLA government after having supported its rivals during the civil war.

Neto told McGovern and a group of five American correspondents accompaning him on his visit here that the Cuban troops here were "mainly a problem regarding South Africa because we are being daily attacked by the South Africans."

He charged that South African planes were constantly overflying southern Angolan and its troops making incursions into the country in search of nationalist guerrillas fighting against South Africa in Namibia. He also said South Africa was arming antigovernment dissidents carrying on a persistent if low-scale guerrilla war in the south.

President Neto seemed to be signaling Sen. McGovern that if South Africa stopped these activities, there would no longer be any need for Cuban troops and he would tell them to go home.

At the same time, he made clear his strong desire for American diplomatic recognition, saying Angola was "prepared and desires" it now. He made a similar statement in Khartoum, Sudan, in July.

The United States is the last major Western power without diplomatic representation here. The first British ambassador has just arrived and France is about to send one.

The cubans reportedly played a background role in helping to arrange McGovern trip and seem to be quietly acting to facilitate a rapprochement between Angola and the Nnited States.