Eight years ago, President Obama pledged to wind down the war in Iraq and redouble efforts to defeat the Taliban in Afghanistan. “As president, I will make the fight against Al Qaeda and the Taliban the top priority that it should be,” he said during a campaign speech. “This is a war that we have to win.”

Lasting peace, Mr. Obama said, would depend on not only defeating the Taliban but helping “Afghans grow their economy from the bottom up.” He added, “We cannot lose Afghanistan to a future of narco-terrorism.”

Now, at the twilight of his presidency, these goals are receding further into the distance as America’s longest war deteriorates into a slow, messy slog. Yet despite this grim reality, there has been no substantive debate about Afghanistan policy on the campaign trail this year. Neither Donald Trump nor Hillary Clinton has outlined a vision to turn around, or withdraw from, a flailing military campaign.

The war in Afghanistan has cost American taxpayers in excess of $800 billion — including $115 billion for a reconstruction effort, more than the inflation-adjusted amount the United States spent on the Marshall Plan. The Afghan government remains weak, corrupt and roiled by internal rivalries. The casualty rate for Afghan troops is unsustainable. The economy is in shambles. Resurgent Taliban forces are gaining ground in rural areas and are carrying out barbaric attacks in the heart of Kabul, the capital. Despite an international investment of several billion dollars in counternarcotics initiatives, the opium trade remains a pillar of the economy and a key source of revenue for the insurgency.