Golden_Brown/iStock(WASHINGTON) — President Donald Trump has made clear his desire to end the U.S. war in Afghanistan. But as his negotiators finalize agreements with the Taliban and the Afghan government, the violent reality of the conflict has shown how delicate or even far-fetched a final deal may be.

In particular, a spate of deadly bombings on Monday as Afghans marked 100 years of independence and a brutal attack on a wedding Saturday in the capital Kabul have rocked the country.

An Islamic State affiliate claimed responsibility for the Saturday attack, killing 63 people and injuring 182 more. Beyond the horror of a wedding party turned into a funeral — the dance floor filled with dead bodies — the assault is also a sign of the group’s growing strength — and the challenge that poses to the U.S. president who wants to pull troops out.

“We’re there for one reason. We don’t want that to be a laboratory, OK? Can’t be a laboratory for terror. And we’ve stopped that,” Trump told reporters Sunday, despite the deadly wedding attack.

While there hasn’t been an effective Afghanistan-based plot on the U.S. by terror groups like al-Qaeda or ISIS for years, the issue of counter terrorism — what brought American troops to the country nearly 18 years ago — remains an elusive challenge.

For one thing, the Pentagon and State Department say the local ISIS affiliate is now stronger than ever. The group has carried out dozens of attacks, killing nearly 800 people and injuring over 1,400 in the last year, according to Ambassador-at-Large for Counterterrorism Nathan Sales.

When asked if this ISIS affiliate presented a risk to the U.S., Sales said, “Any ISIS affiliate around the world that has the capability and intent to conduct external operations is a threat to the United States and our partners and our interests.”

The Afghan government said Monday that it will crush the terror group, while the Taliban condemned Saturday’s attack as “forbidden and unjustifiable.” But there are real concerns about the ability of either to effectively take on ISIS and prevent it from growing or plotting attacks overseas.

To that end, Trump said he wants the U.S. to ultimately keep an intelligence presence in the country.

“It’s very important that we continue intelligence there, in all cases, because it is somewhat of a nest for hitting us,” he said Sunday.

There are approximately 14,000 U.S. troops in the country now, according to the Pentagon, 5,000 of which are on a counter terrorism mission with the other 9,000 training and supporting Afghan forces.

But while the U.S. hopes to keep some military presence, the Taliban have pushed for a total withdrawal. Finalizing those details — how many U.S. troops in what role must leave by when — has been at the heart of U.S. talks with the Taliban.

Led by former U.S. ambassador to Afghanistan Zalmay Khalilzad, the talks have been through eight rounds now and taken about a year. Khalilzad briefed Trump on Friday, along with Vice President Mike Pence, Secretary of State Mike Pompeo, Defense Secretary Mark Esper and Gen. Joseph Dunford, the chairman of the Joint Chiefs of Staff. It’s a sign that Khalilzad and his team are close to a final deal with the militant group — one that the U.S. hopes will have four pillars, according to officials: American troop withdrawal, a nationwide ceasefire, Afghan peace talks and a commitment by the Taliban to keep Afghanistan from becoming a terror safe haven.

Khalilzad said Sunday that the wedding attack shows, “We must accelerate the Afghan peace process, including intra-Afghan negotiations. Success here will put Afghans in a much stronger position to defeat ISIS.”

But the Taliban still refuses to recognize the Afghan government, let alone meet with it or commit to work together to combat ISIS. In negotiations, the U.S. has struggled to win such a commitment and define what it entails and how to implement it — especially given that the Taliban maintains ties with al-Qaeda.

Critics say Saturday’s attack is a clear demonstration that the militant group, which is itself considered a terror organization under some U.S. law, can’t credibly make that kind of commitment.

The challenge is that the Taliban has the upper hand in negotiations, knowing well that Trump wants to fulfill a campaign promise to end America’s endless wars and start bringing troops home.

Pompeo said at the end of July that it was his “directive” from Trump to begin a withdrawal before next November, adding, “It’s not only my expectation. It would be job enhancing.”

Trump himself said in August 2017 that his instinct was to pull out American forces, but he had been convinced by his advisers to increase troop numbers at the time.

Officials have tried to paper over that desire, consistently saying any withdrawal would be “conditions-based.” Trump said on Sunday that he is still weighing a decision.

“We’ll be bringing it down a little bit more, and then we’ll decide whether or not we’ll be staying longer or not,” he said.

But what’s clear from him, Pompeo and others is that any decision will be based on U.S. priorities and not include a commitment from the Taliban to the Afghan government, which has not seen any draft agreements from the talks or the Afghan people.

Those issues, including the continued violence by the Taliban against Afghan civilians, are an internal matter, officials say, and up to the Afghan people to determine.