The British knew how to turn their two offensive wars against the Afghans into geopolitical victories and so did the Soviets after being militarily stalemated against the Afghans in the 1980s: pick a side, withdraw, fund the side from a distance, and watch our side decimate all its opponents. This strategy worked well for the British and it was working well for the Communists in Afghanistan... until the funds ran out with the collapse of the Soviet Union.
In a perfect world the United States and the other Coalition Partners could just withdraw from Afghanistan while funding the Kabul-based government known as GIROA. GIROA would bribe many of the Taliban and other insurgents and use the remainder of the funds to crush the rejectionists. Most Afghans would see this more as a upper level Afghan civil war and much of the anger of the average insurgent would be soothed over by the lack of foreign troops in Afghanistan.
I say "in a perfect world" because this world unfortunately as what Afghans have described to me as the root of all evil: Pakistan. Pakistan desire to have a puppet state linking it to Central Asia, a proving ground for its proxies for war against India, and its absolute paranoid belief that anything less than an Islamist Afghanistan will automatically make Afghanistan an ally of India will cause Pakistan to fund the insurgency. Unless Pakistan collapses or the United States cuts off foreign aid to Pakistan (which forms much of Pakistan's budget) I do not see Pakistan stopping its funding of the Taliban and related groups.
If the problem of Pakistan can magically disappear then groups and/or factions like the Taliban, Haqqani network, and Hezb-e-Islami Gulbuddin will enter in complex agreements of becoming loyal to GIROA while being able to have significant sway in territory they control. Afghans will then probably be less of the highly centralized state it has been under the monarchy/Communists/republicans and more of the regionalist state tied by a central government which is was like before the British wars.
If the Pakistan problem cannot be solved then expect a long war ending in the favor of Pakistan and the Taliban. Maybe not a complete victory like it was becoming before 9/11 but certainly one that ends in their favor.