In a White House often accused of being stacked with loyalists, President Obama’s national security adviser said Wednesday there are too many white people in key government posts, endangering national security because they think alike.

Speaking at Florida International University’s commencement, Susan E. Rice, who is black, said a diversified government workforce is more likely to yield “better outcomes” than a predominantly white one.

Referring to criticism that the U.S. national security workforce is “white, male and Yale,” Ms. Rice told the graduates, “In the halls of power, in the faces of our national security leaders, America is still not fully reflected.”

SEE ALSO: U.S., Russia fine tune deal to share Syrian airspace

“By now, we should all know the dangers of ‘groupthink,’ where folks who are alike often think alike,” she said. “By contrast, groups comprised of different people tend to question one another’s assumptions, draw on divergent perspectives and experiences, and yield better outcomes.”

Her comments were reminiscent of Supreme Court Justice Sonia Sotomayor, who said in a speech in 2001, before Mr. Obama appointed her to the high court, “I would hope that a wise Latina woman with the richness of her experiences would more often than not reach a better conclusion than a white male who hasn’t lived that life.”

Ms. Rice elaborated in her speech on how having more minorities in the national security field would better protect the homeland.

SEE ALSO: White House calls waste study ‘pathetic’

“Intelligence analysts, diplomats and military officers who are native speakers may pick up subtle nuances that might otherwise go unnoticed,” she said. “Diplomats who can read cultural cues may better navigate the political and social currents of a foreign nation. In sum, leaders from diverse backgrounds can often come up with more creative insights, proffer alternative solutions and thus make better decisions.”

White House press secretary Josh Earnest said Mr. Obama agrees with that sentiment.

“The president certainly believes that our government is most effective and is making the best decisions when we have a government that looks like the country,” he said.

Mr. Obama has been criticized for increasingly surrounding himself with an inner circle of aides who think like him and reject advice outside the West Wing, particularly from the Pentagon. In his second term, he is said to rely most heavily on a handful of trusted advisers, including chief of staff Denis McDonough, a former NSC official; Ms. Rice and her deputy, Ben Rhodes; U.N. Ambassador Samantha Power; Treasury Secretary Jack Lew; and Vice President Joseph R. Biden.

The president often hits back at his critics, saying he doesn’t surround himself with “yes men” and that he presses his advisers for all points of view during internal policy debates. Still, former Defense secretaries of both parties such as Leon Panetta and Chuck Hagel have said they felt shut out sometimes by the president’s cadre of West Wing advisers.

In her speech, Ms. Rice also made an apparent reference to presumptive Republican presidential nominee Donald Trump when she criticized “voices out there that disparage our diversity — that question whether America should welcome people of all races, religions and creeds.”

“Those voices can be loud. They can be intimidating,” she said. “They can make us feel like we don’t belong. Let fear be their problem, not yours. Shake it off. Ignore the haters.”

The daughter of Jamaican immigrants, Ms. Rice was a leading contender to become secretary of state in President Obama’s second term, but she fell out of contention after the storm of controversy over her role in the administration’s “talking points” on the Benghazi terrorist attack in Libya. The attack, which killed U.S. Ambassador J. Christopher Stevens and three other Americans, was blamed initially by Ms. Rice and other top officials on a spontaneous riot over an anti-Islam film produced in the U.S.

When it became clear that Senate Republicans would not tolerate her nomination as the nation’s top diplomat, Mr. Obama appointed her as his national security adviser instead, a post that doesn’t require Senate confirmation.

In her commencement speech, Ms. Rice said U.S. national security agencies “have not yet drawn fully on the strengths of our great nation.”

“Minorities still make up less than 20 percent of our senior diplomats [and] less than 15 percent of senior military officers and senior intelligence officials,” she said.

“Why should we care? For starters, a diverse national security workforce enables us to unlock all of our nation’s talent,” Ms. Rice said.

About 82 percent of career Foreign Service officers are white, according to the State Department. Seven percent are Asian American, 5.4 percent are black and 5 percent are Hispanic. About three-fifths of them are male.

More than 25 percent of the State Department’s civil servants are black, while 6.3 percent are Asian and 5 percent are Hispanic.

Mr. Earnest said he didn’t believe Ms. Rice was criticizing the president, who has been in office nearly eight years, for the lack of diversity in senior diplomatic and national security posts. He noted that Mr. Obama has appointed more minority judges, about 120, to the federal bench than any other president.

“The president has made it a concerted effort to encourage Americans of all backgrounds to consider a career in public service,” he said. “The best way for us to ensure over the long term that the senior ranks of government positions are filled by people who reflect the diversity of this country is to ensure that … they’re considering a career in public service. Giving more minorities in particular the opportunity to start a career in public service and rise through the ranks means that future presidents will have a much more diverse pool of applicants to consider when making senior-level appointments.”

He said the impact won’t be seen in the short term.

“But the president is hopeful that 15 or 20 years from now that a future president will have a more diverse pool of applicants to choose from when considering senior-level government appointments,” he said.