Eight years ago, Barack Obama premised his foreign policy on the idea that the Iraq War was a distraction from the real task at hand in Afghanistan. Anyone think he has completed the task there?

Obama himself isn't so sure. In the past month, he announced a further drawdown of American troops in Afghanistan, from 9,800 to 8,400. It was an alteration of his plan to keep just 5,500 troops there. It seems he wants to keep just enough troops to prevent a disaster on his watch, but just few enough to look like he's living up to his promise of finishing the job.

But it is becoming clearer by the day that America is losing the longest war in its history. After it removed the Taliban from government 15 years ago, the Taliban is recapturing larger parts of the country, making governance of the nation's far-flung regions from Kabul impossible, and doing the most violence it has in years. Afghanistan's civilian casualty rates this year are near record levels.

What was it all for?

Obama's strategy in Afghanistan has been confused. He invested in a surge, which made America's operation there an extremely large counter-terrorism force. But he never went all-in for a counter-insurgency strategy or in building up the Afghan government. This meant more American casualties for a time. And it also meant more successes against the Taliban. But almost as soon as these victories started to come in 2012, Obama began withdrawing.

The president had soured on the war he had preferred to fight. And he showed it in the exact same way that George W. Bush did on Iraq. The much touted surge in Baghdad and Anbar province turned out to be less of a long-term strategy for Iraq than a face-saving strategy for America's eventual exit.

Just as in Iraq, instead of routing an insurgent force, the Obama administration temporarily overwhelmed it and drove it into hiding in its traditional redoubts. As the drawdown picked up speed in 2012 and 2013, the Taliban regained their momentum, and even some of their territory. Naturally, these gains eroded any efforts at improving the governance of the country.

Paul D. Miller relays:

The Defense Department reported at the end of 2013 that, "the insurgency has also consolidated gains in some of the rural areas in which it has traditionally held power." Real estate prices in Kabul fell and applications for asylum skyrocketed. Civilian fatalities, which had declined in 2012, rose to an all-time high in 2014. The number of internally displaced persons in Afghanistan exploded, nearly doubling from 352,000 in 2010 to 631,000 in 2013. [American Interest]

And in a way that seems naive now, Obama premised the scheduled drawdown on the idea that it would create pressure on the Afghan state to improve the level of governance it offered and to reform itself. Even now, over a quarter of 407 administrative districts in Afghanistan are controlled by insurgent groups, or at risk of falling into their hands. Opium production in Afghanistan has skyrocketed after a lull during the surge. And American efforts to help the Afghan government build proper infrastructure, electricity, schools, and a working military of its own, have been only modest successes.

Without a major breakthrough in halted negotiations with insurgents, there is no plausible ending where America gets out of Afghanistan entirely, without the Taliban putting the government in Kabul into mortal danger almost immediately. Despite some good-faith efforts by Afghanistan's national unity government to root out corruption, the black clouds gathering on the horizon seems to have driven corruption into overdrive, as jobbers, apparatchiks, and officials who are really in a helpless position, try to get as much as they can out of the government before it falls to the ground.

The Afghanistan war has been a demoralizing one for America's policy elite and its military. Yes, many al Qaeda operatives were killed and networks disrupted in the past 15 years. But, it has become obvious now that complete victory over the Taliban in Afghanistan alone would require more blood and treasure than Americans are willing to invest. Beyond that, it would require a much more difficult confrontation with America's long-term "ally," Pakistan, which has operated as a rear-operating base for the Taliban.

So instead, America's longest war will almost certainly end in defeat.