Peter Bergen is CNN's national security analyst, a vice president at New America and a professor of practice at Arizona State University. He is the author of "United States of Jihad: Investigating America's Homegrown Terrorists." This article has been updated with commentary on President Trump's speech on Afghanistan.

(CNN) The seriously deteriorating situation in Afghanistan -- and what to do about it -- is a deeply personal issue for Trump's top national security advisers and generals.

In the months after the 9/11 attacks, Trump's secretary of defense, retired Marine four-star General James Mattis, led the deepest assault from a ship in Marine Corps history near the key Taliban city of Kandahar in southern Afghanistan.

Trump's top military adviser, the Chairman of the Joint Chiefs Marine Gen. Joseph F. Dunford, was the commanding general in Afghanistan in 2013.

And General John Kelly, the retired four-star Marine general who is now Trump's chief of staff, lost a son in Afghanistan, 29-year-old Marine 1st Lt. Robert Kelly who was killed by a landmine there in 2010.

Four days after his son's death, in a speech in St. Louis, Kelly said that the United States' war against jihadist terrorists will go on for a very long time. "The American military has handed our ruthless enemy defeat after defeat, but it will go on for years, if not decades, before this curse has been eradicated," he said at the time.

So when it came to developing a new strategy for Afghanistan, the generals brought a degree of commitment to the longest war in US history that their commander in chief, at least initially, did not share.

In 2013, for example, Trump tweeted , "Let's get out of Afghanistan. Our troops are being killed by the Afghanis we train and we waste billions there. Nonsense! Rebuild the USA."

The generals had a different view of what was at stake.

Generals Mattis, Kelly and Dunford have fought alongside each other since the 2003 invasion of Iraq. Then-Major General Mattis, then-Brigadier General Kelly and then-Colonel Dunford led the Marine force that went into Iraq in March 2003 during the initial US invasion of the country.

All of them experienced the visceral sense that US forces leaving Iraq at the end of 2011 helped pave the way for the collapse of the Iraqi army in the face of ISIS's campaign in Iraq in 2014.

None of them wanted the same scenario to play out in Afghanistan, where the Taliban is at its strongest point since 9/11 and a virulent local affiliate of ISIS has established itself.

These Marine generals also know how hard-fought were the battles in the southern Afghan province of Helmand, where 349 Marines died in a campaign that began there in 2009 and ended in 2014.

Now 300 Marines are back in Helmand because the Taliban have recently regained territory the Marines had seized there several years ago. The Taliban also control or contest about a third of the Afghan population, around ten million people.

Monday night President Trump delivered an unusual prime-time address from Fort Myer in Arlington, Virginia about what his Afghanistan and larger South Asia strategy will be.

The well-delivered, well-written and well-argued speech largely reflected the consensus views of the generals and of the American national security apparatus.

As President Trump conceded in the speech, "My original instinct was to pull out. And historically, I like following my instincts."

But Trump acknowledged that "a hasty withdrawal would create a vacuum for terrorists, including ISIS and Al Qaeda, would instantly fill just as happened before Sept. 11. And as we know, in 2011, America hastily and mistakenly withdrew from Iraq. As a result, our hard-won gains slipped back into the hands of terrorists."

Trump also had stern words for Pakistan, a common theme of the American military: "Pakistan often gives safe haven to agents of chaos, violence and terror."

Trump also made clear the American commitment to Afghanistan will be conditions based: "A core pillar of our new strategy is a shift from a time-based approach to one based on conditions. I've said it many times how counterproductive it is for the United States to announce in advance the dates we intend to begin or end military options."

This was an implicit criticism of the Obama administration's approach to Afghanistan. President Obama surged tens of thousands of additional US troops into Afghanistan in 2009, but he also simultaneously announced their withdrawal date. The Trump administration isn't planning to repeat what it sees as a grave mistake.

But he also said, "America will work with the Afghan government as long as we see determination and progress. However, our commitment is not unlimited, and our support is not a blank check. "

Trump's national security advisers and generals with deep experience in Afghanistan had advised against the complete withdrawal that was Trump's first instinct and also against the notion of using contractors as substitutes for US soldiers.

Both these options were on the table as the Trump national security team discussed the options in Afghanistan.

Those options were being pushed, in part, by Trump's chief strategist Stephen Bannon, who was forced out of the White House on Friday.

Bannon didn't attend the final war cabinet meeting on Afghanistan that Trump hosted at Camp David on Friday.

A decision to use American contractors in battlefield roles would face a number of legal obstacles, not least that they would be subject to Afghan laws.

For these reasons, privatizing the Afghan war and outsourcing it to contractors or withdrawing completely were really non-starters during the war cabinet's deliberations on Afghanistan.

Follow CNN Opinion Join us on Twitter and Facebook

The United States' key strategic goal in Afghanistan is to prevent the country from being taken over by jihadist groups such as the Taliban, al-Qaeda and ISIS, allowing the country to be once again used as a launching pad for attacks against the United States and its allies, as it was on September 11, 2001.

So far, that goal has cost the lives of 2,403 American soldiers.

Trump's top national security advisers and generals understand both the stakes and the costs of the Afghan War well, because they have been personally deeply affected by it.

In the end, Trump came around to their view.