WASHINGTON — The war in Afghanistan has cost American taxpayers more than $1 trillion, but has produced at best a faltering democracy and — most tragically — has resulted in the deaths of nearly 115,000 civilians, military forces, humanitarian aid workers and journalists.

Still the United States persists in the fight.

New documents reveal extraordinarily detailed warnings of failure from officials at the highest levels of the United States government about the 18-year war.

Obtained by The Washington Post, the documents are part of an investigation by the Special Inspector General for Afghanistan Reconstruction that sought to identify lessons learned in the war so that they might not be repeated in future American conflicts.

Some of the broad strokes of the findings were well known. But they are sure now to fuel a simmering debate over when, and how, to end the United States’ war in Afghanistan. American and Taliban negotiators are trying anew to broker a peace agreement that would see the withdrawal of the 13,000 forces currently in Afghanistan, as President Trump has pledged.