Elliot Ackerman is the author of several novels. His memoir, “Places and Names: On War, Revolution, and Returning,” will be published in June.

In the years since Pfc. Bowe Bergdahl walked off his platoon’s base in eastern Afghanistan in the early hours of June 30, 2009, he has become many things to many people, from a conscience-driven whistle-blower to a traitorous Taliban collaborator. What would compel a 23-year-old soldier to leave his weapon behind and wander off into hostile territory with nothing more than some water, food, a compass and $300 in cash? The compelling new book “American Cipher: Bowe Bergdahl and the U.S. Tragedy in Afghanistan” by Matt Farwell and Michael Ames attempts to answer these questions or at least to place a framework around them.

In “American Cipher,” Farwell and Ames tell Bergdahl’s story alongside a history of the Afghan war. A deft move, as it is impossible to understand Bergdahl’s actions outside a deeper contextualization of that conflict, with its many contradictions. That is because the arc of Bergdahl’s story draws such strong parallels with the American experience in Afghanistan. Which leads to the bitterest irony of all — particularly among many veterans — that the most iconic figure of the war in Afghanistan, a war deserted by many Americans, is in fact a deserter himself.

Within a month of arriving in Afghanistan, Bergdahl had become disillusioned. “The war he had been sold was a lie, he thought, a con spun from the desire in the American heart to spread freedom and liberate the tyrannized peoples of the world,” the authors write. “This wasn’t the war story Bergdahl had written for himself, so he decided to write his own.” Having chosen to take matters into his own hands, Bergdahl became convinced that he needed to address his grievances to at least a general officer.

His plan — he claimed — was to walk 18 miles from his small combat outpost to the nearest large base, where, after having instigated the crisis of a soldier “missing in action,” he would become his command’s savior by appearing and, thus, be granted the audience he desired. “They might think he was crazy,” Farwell and Ames write, parsing Bergdahl’s logic, “but they would respect what he’d done and hear his concerns.” But instead Bergdahl was captured by the Taliban and held in captivity for five years. After his release, he said of his mental state when he walked away from his platoon’s base: “Happily with my ignorance, from a young man’s mind and my imagination, I came up with a fantastic plan.”

Delusion factors heavily into Bergdahl’s understanding of his actions. At his court-martial, his defense team diagnosed him as schizotypal. Unlike schizophrenics, schizotypal patients don’t suffer from complete breaks with reality but often become lost in their own fantasies. If Bergdahl suffered the delusion of believing he could become a savior by solving a crisis of his own making, the case is artfully made in “American Cipher” that America itself is a schizotypal, that we became lost in our own fantasies for Afghanistan, in which we could deliver the Afghan people from a crisis we created.

In “American Cipher” the specific facts of Bergdahl’s case are elevated to the allegorical, and this is where Farwell and Ames’s storytelling really shines. The U.S. government’s interdepartmental dysfunction when negotiating with the Haqqani network, which was holding Bergdahl, mirrors the government’s dysfunction in nascent Taliban peace talks brokered by then-special envoy Richard Holbrooke. The dysfunctional recruiting process of an overextended U.S. military mirrors the specifics of Bergdahl’s recruitment into the Army, even though the government knew of his psychological issues. And when Bergdahl deserts, the dysfunction of the military’s counterinsurgency strategy mirrors the dysfunction of U.S. attempts to elicit intelligence about Bergdahl from a distrustful Afghan population.

The parallels go depressingly on. Farwell and Ames convincingly show that so many of the reasons we’ve been fighting in Afghanistan for 18 years — bureaucratic inertia, partisan dysfunction, domestic indifference — are the same reasons that, even when Bergdahl’s captors eagerly hoped to broker his release, it took so long to recover him.

And when we did recover Bergdahl, the cost of his actions, particularly for his former comrades and those sent to search for him, became acutely evident. Some of the most moving pages in the book recount the testimony of Shannon Allen, whose husband, Mark, was shot in the head when he was sent to a remote part of eastern Afghanistan to track down information on Bergdahl. Mark Allen remains largely in a vegetative state despite at times responding to prompts from Shannon and their young daughter. On the witness stand Shannon said, “Instead of a wife, I am a caretaker,” at which point the prosecution showed a video of the Allens’ daily routine, in which Mark is fed through a tube and wears a percussion vest to prevent fluid from collecting in his lungs, and Shannon crushes pills for his 80-odd prescriptions. Watching the video, Shannon concluded through tears that at least Mark was back home, “where he’s safe.”

Following Shannon Allen’s testimony, Bergdahl took the stand. He read a prepared apology in which he said: “I made a horrible mistake. . . . People went through things that they never should have. I was trying to help, and the fact that I did not breaks my heart.”

On rebuttal, the lead prosecutor, Maj. Justin Oshana, challenged Bergdahl’s choice of words. “It wasn’t a mistake,” he said. “It was a crime.”

Whether Bergdahl’s actions were a mistake or a crime is the central question of “American Cipher.” In light of the amount of suffering his actions caused, it’s a fair question to ask of Bergdahl. And in light of our nearly 20-year misadventure in Afghanistan, it is also a fair question to be asking of ourselves.

American Cipher

Bowe Bergdahl and the U.S. Tragedy in Afghanistan

By Matt Farwell and Michael Ames

Penguin Press. 388 pp. $28