You wouldn’t expect a C.I.A. agent to talk like the spiritual presidential candidate Marianne Williamson. But there was Amaryllis Fox, who spent much of her 20s trying to keep nuclear materials out of terrorists’ hands, talking about love and kindness.

“They are human, and they’re in the midst of waging a war that involves horrendous, unforgivable crimes against humanity,” she said, “but the way to get to the end of that war is to understand their humanity, rather than deny it.”

Ms. Fox reached that conclusion after eight years traveling the world, posing as an art dealer while she recruited arms dealers as assets and tried to talk extremists out of detonating dirty bombs. She tells that story in searing detail in her memoir, “Life Undercover: Coming of Age in the C.I.A.,” which comes out on Oct. 15. “There is just nothing like sitting with someone and being in their energy and understanding them,” she said.

I told her not to take it the wrong way, but she reminded me of Ms. Williamson, the New Age author and guru whose quixotic quest for the Democratic presidential nomination includes establishing a Department of Peace. “I won’t take it the wrong way! I love her!” Ms. Fox said.

The former spy was curled up in a sort of lotus pose in a corner booth at the TriBeCa restaurant Odeon. She wore black pants and a black tank top that showed a Farsi tattoo of a Rumi quote down her backbone: “Out beyond ideas of wrongdoing and rightdoing, there is a field. I’ll meet you there.”

The corporate lunchtime crowd was a far cry from the gritty locations referred to in Ms. Fox’s book (a prison in Myanmar, a terrorist’s cell in Karachi). But in a way, her story all started here, in Lower Manhattan.

She writes in her book that on Sept. 11, 2001, she was at home in Washington, D.C., visiting her mother and sisters before starting her final year at Oxford. She decided to pursue a master’s degree in conflict and terrorism at the School of Foreign Service at Georgetown University.

As part of the program, Ms. Fox designed an algorithm (“ratio of hookah bars to madrassas and percentage beneath livable wage a border guard gets paid”) to identify likely terrorist safe havens. The C.I.A. headquarters in Langley, Va., heard about “the algo” and recruited Ms. Fox, who at 22 became one of the youngest female officers.

The agency assigned her to “nonofficial cover,” meaning an agent must live abroad “in the most dangerous places the planet has to offer” under a false identity with no diplomatic protections or official passport, Ms. Fox writes.

The story that ensues reads as if a John le Carré character landed in “Eat Pray Love” — fast and thrilling when Ms. Fox is on missions but also aching in its loneliness. Ms. Fox’s first marriage, to a civilian, was annulled. Her second, to a hunky C.I.A. officer haunted by his multiple tours of Afghanistan, ends in divorce.

When Ms. Fox’s first daughter, Zoe, was born, she was living undercover with Dean, both of them pretending to be art entrepreneurs in Shanghai. The Chinese spied on the couple, including installing a live-in housekeeper who was an informant. The C.I.A. spied on the Chinese spying on their spies.

“The only way to handle being watched is to give the watchers nothing to see,” Ms. Fox writes. The C.I.A. even briefed the couple to have “sex regularly, but not too regularly, keep it hot but not too hot.”

At one point her infant senses something is off and won’t make eye contact. “Nobody has briefed Zoe on the mission and she doesn’t play her role right,” Ms. Fox writes.

Ms. Fox, now 38, left the C.I.A. in 2010. She and Zoe, 11, live in Los Angeles with Ms. Fox’s new husband, Robert F. Kennedy III, the son of Robert Kennedy Jr., and the couple’s 8-month-old daughter, Bobcat (a take on “Bobby” Kennedy). Ms. Fox met Mr. Kennedy through a mutual friend at Burning Man — “We weren’t just wandering around in the desert,” she clarifies — and they got married on Cape Cod last year.

So what’s it like to date as a former spy? “You sort of have to get through the questions that come up, like ‘Can you kill me with your pinkie finger?’ and you’re like, ‘No, it’s not like that,’” Ms. Fox said.

She has been thinking a lot about the Hollywood portrayal of her former profession now that Apple is developing a TV series based on the book that will star Brie Larson. Ms. Fox is an executive producer on the series and has mostly served as a sounding board for Ms. Larson.

In an email, Ms. Larson called Ms. Fox “the definition of strength and bravery” and said they had discussed not just Ms. Fox’s experiences in the C.I.A., “many of which defy comprehension when you think about the risks she’s taken and the gender barriers she’s broken,” but also “food, travel and even breastfeeding.”

Ms. Fox shares plenty of made-for-Hollywood secrets in the book, including scrawling signal marks on bricks with Rolaids (“it’s less incriminating than chalk”) and communicating with sources via Starbucks gift cards.

“If you need to see me, buy a coffee,” Ms. Fox tells sources. She checks the balance on the cards each day at different cybercafes. Need an alternative to sending emails? “Write a message, save it to drafts, ensure that the recipient has the account’s email address and password, and wait for him or her to log in and read it.”

But she also tried to counter the cat-and-mouse depictions of C.I.A. officers sprinting through crowds of hijab wearers in Arab markets. “There’s no scene in the book where people are jumping off rooftops,” Ms. Fox said. (In real life, her cover would be blown by a single chase.) “I specifically chose interactions from my past that were very calm and soulful.”

In one of the more soulful scenes in “Life Undercover,” Ms. Fox tries to negotiate with the leader of a Qaeda terrorist cell planning an attack in Pakistan as his infant daughter wheezes in the background.

Ms. Fox recommends clove oil, a home remedy that worked for Zoe, born into the congested Shanghai air. “He gives me a look of knowing sympathy, parent to parent, lamenting government’s inability to keep the air clean,” Ms. Fox writes. The attack never happens.

That account in particular has raised some eyebrows in the intelligence community. “For real?” The Washington Post wrote, calling the exchange “wild to the point of defying belief.” Four former C.I.A. officers told NBC News that the agency would not have sent an American case officer alone to a perilous meeting in Pakistan.

I asked Ms. Fox about the criticism, and she pointed to a disclaimer in the book that says names, locations and operational details had been changed to protect intelligence sources and methods. “I think it’s pretty funny that the journalist who wrote that article called it a ‘controversy,’ when it says on Page 1 that operation details have been changed,” Ms. Fox said, referring to the NBC article.

We had initially planned to meet on the anniversary of the Sept. 11 attacks, but Ms. Fox’s book’s publication ran into some red tape after the journalist Yashar Ali reported that the C.I.A. had not cleared her book for publication before galleys went out, as is required by law. I got a panicked call from a publicist at Knopf to reschedule. (The C.I.A. did not respond to an email requesting comment.)

Ms. Fox couldn’t talk about her private discussions with the agency but said the C.I.A. had been aware of the book from the outset. “I knew before I set pen to paper what the guidance was in my case and what details needed to be changed, and I felt as though it was very doable because it’s not an operational story — it’s a coming-of-age story,” she said.

Ms. Fox is now working on a young adult novel and will host an upcoming Netflix documentary series about the war on drugs, a project that required her to travel to Kenya, Thailand, Myanmar and Colombia, where she embedded with the military. “I did the whole thing in my third trimester,” she said.

That tension between Ms. Fox’s personal life and professional calling is something she has wrestled with, both in the book when she straps Zoe to her chest ahead of clandestine meetings (tucking concealment devices into diapers) and in her current work, going deep into Zika country while pregnant to shoot the documentary.

“Is our job to be at home reading ‘Goodnight Moon’ every night, or is it to go out and make the world we’re going to gift our kids better?” Ms. Fox said. “The answer is both, but how do we do that?”

Follow New York Times Books on Facebook, Twitter and Instagram, sign up for our newsletter or our literary calendar. And listen to us on the Book Review podcast.