Anyone who closely followed the U.S. war in Afghanistan since Oct. 7, 2001, knew it would end badly. The news that the U.S. has reached an agreement with the Taliban for a peace framework is indeed a positive development, but it masks the fact that the war has largely been futile and destructive—and that the Taliban is the likely victor.

Over the past 18 years, the U.S. went from considering the Taliban an inconsequential enemy that would be easily defeated to negotiating with the dictatorial regime to now seemingly capitulating to its demands. This disastrous trajectory of events is well worth examining as the history of the United States’ longest war is written.

In the days after the Sept. 11, 2001, terrorist attacks, President George W. Bush flatly refused the Taliban’s offer to try Osama bin Laden in Afghanistan. Instead, he launched a war on what was one of the poorest nations in the world, already devastated by decades of violence by U.S.-backed and -armed fundamentalist groups. In what might be viewed as “famous last words,” the Bush White House warned the Taliban, “We will defeat you.” Bush’s stated objectives in Afghanistan (aside from buying time to build a case for the more desired war in Iraq) included “to disrupt the use of Afghanistan as a terrorist base of operations and to attack the military capability of the Taliban regime.” Bush flip-flopped on his pledge to never engage in “nation-building” and adopted the lofty goal of rebuilding Afghanistan’s government. Writing about it in his memoir, he said, “Afghanistan was the ultimate nation building mission. We had liberated the country from a primitive dictatorship, and we had a moral obligation to leave behind something better. We also had a strategic interest in helping the Afghan people build a free society,” because “a democratic Afghanistan would be a hopeful alternative to the vision of the extremists.”

Perhaps it is fitting that the man now in charge of negotiating with the Taliban in President Donald Trump’s administration is Zalmay Khalilzad. Khalilzad’s claim to fame was his Bush-era role as special envoy for Afghanistan from 2001 to 2002, when he oversaw the crafting of a transitional government that had the outward hallmarks of democracy but was designed to fit U.S. interests and appease fundamentalist and Taliban-like warlords, and had little bearing on the aspirations of ordinary Afghans. After helping to craft the new Afghan constitution, Khalilzad said, “We are witness to a major milestone in putting behind the era of the rule of the gun in Afghanistan.” At the same time, he was cementing the power of armed groups with a history of violent oppression. His words were just as futile and disingenuous as Bush’s claim of certain victory over the Taliban. The Bush plan to build a stable Afghan government as a bulwark against the Taliban and al-Qaida failed for reasons that had as much to do with imperial hubris as it did with the practical shortcuts taken by an outsider to patch together a precarious government—as if that were a sufficient substitute for real democracy.

Cut to a few years later, when the Bush presidency ended and a naive Barack Obama was enthusiastic about negotiating with “moderate” elements of the Taliban. The next eight years were an embarrassing parade of failed talks between the U.S. and the Taliban, as well as between the U.S.-backed Afghan government and the Taliban—failures that made headlines in 2011, 2012, 2013, 2014 and 2016. Obama’s strategy included a temporary increase in troops, as if throwing more American soldiers at the problem would help any one of his goals stick. He also adopted a set of vague objectives similar to those of his predecessor but with the end goal of strengthening the weak and corrupt Afghan government so that it could deal with the Taliban on its own. In the end, Obama broke his promise to end the war in Afghanistan. Seven years ago, Khalilzad explained in an interview that the U.S. remained in Afghanistan because “[t]here’s a reputational dimension of it that after investing so much, America’s prestige is involved.” And so, perhaps, we remained because it was too embarrassing to leave at that time.

The Taliban appears to have had a “wait it out” strategy with respect to Americans, stringing along the U.S. and the Afghan government over several years of talks until it had the upper hand to return to power. Cut to today, and that long game seems to have paid off, with Trump itching to withdraw. In an interview with The New York Times on Monday, Khalilzad announced a tentative framework for a peace agreement, saying, “The Taliban have committed, to our satisfaction, to do what is necessary that would prevent Afghanistan from ever becoming a platform for international terrorist groups or individuals.” On its face, this is either supremely naive or a purposeful ignoring of the fact that Islamic State has already gained a strong foothold in Afghanistan and that neither the Taliban nor the Afghan government have been unable to fight it off.

Meanwhile, the Taliban itself has been continuing to behave like a terrorist group (as it always has done), repeatedly perpetrating deadly attacks, such as one that took place a mere two days before Khalilzad’s announced framework for a peace agreement, which killed 95 people in Kabul. Days earlier, the Taliban claimed responsibility for an attack that killed four and wounded 100 in Kabul. The attacks are ongoing and relentless. The United States’ continued negotiations with the very group launching violent attacks in the Afghanistan’s capital suggests that Trump’s approach is to throw our own flawed creation (the Afghan central government) under the bus in order to appease the original enemy it pledged to destroy. And Khalilzad’s role as American representative has bookended both bloody ends of a long, needless war.

A journalist with the Afghan media outlet Tolo News recently questioned Khalilzad about the United States’ motives, asking, “Why do the Taliban negotiate with you, the U.S., but do not negotiate with the Afghan government and Afghan people?” To that, Khalilzad had no good answer.

Had the U.S. envoy been honest, he would have explained that the grand plan to transform Afghanistan into a democracy by force was an imperial fantasy whose time has come to an end, and that the U.S. is simply going to cut its losses and hand the country back to the very enemy it claimed to have been fighting for more than 18 years. Had he been honest, he might have admitted that not only is it well past time for the United States’ longest official war to end, it should have never been launched in the first place.