Javid Ahmad is a senior fellow at the Atlantic Council.

The United States is on the verge of sealing a landmark deal with the Taliban in hopes of ending America’s longest war. While this is potentially a welcome development, there are some serious flaws in the process that could promise chaos. Amid the growing uncertainty and ongoing violence plaguing the country, the emphasis ahead should be on creating a degree of predictability about Afghanistan’s future.

There are several key problems with the peace process in its current form. To start with, frictions among the Taliban leaders have raised questions about the practicality of implementing the agreement. Taliban hard-liners see little military reason to compromise. The group’s military commission seems eager for a fixed date for American withdrawal, and then hopes to take over. Some Taliban leaders fear that a peace deal might lead their hard-liners to defect to the Islamic State. Others see the conflict as more profitable than peace. All this casts doubts on whether the Taliban will honor the agreement.

The Afghan government also remains deeply skeptical of the U.S.-Taliban talks, which exclude it from official participation. Members of the government fear that if they are not at the negotiating table, they may well be on the menu. Meanwhile, the peace process has turned into a bargaining tool for other Afghan political leaders, who have pursued competing peace initiatives driven mainly by a desire to manage power rather than the country.

Moreover, Pakistan’s role in the process remains ambiguous. Of course, Pakistan’s significance to the process cannot be overstated. But the recent meeting between President Trump and Pakistani Prime Minister Imran Khan has engendered suspicions among Afghan leaders about whether their country is essentially being outsourced to Pakistan. Also unclear is whether the officers in Pakistan’s military and intelligence apparatus will follow their leader’s approach.

Perhaps most importantly, however, the Afghan government has expressed concerns about some parts of the draft deal itself. For example, beyond a reported reference to the Taliban as an “emirate,” there is confusion over a reference to a “post-peace Islamic government” in one of the drafts of the agreement I have seen. This depiction has unsettled the Afghan government, which interprets it as eliminating the republic system.

Meanwhile, a conditions-based withdrawal timeline will likely see the U.S. troops level significantly shrink within months of the deal, with NATO forces also proportionately reduced. But it is uncertain what this would mean for the status of the existing security agreements signed with Afghanistan, including the U.S.-Afghanistan Bilateral Security Agreement and the NATO-Afghanistan Status of Forces Agreement. These pacts, which provide the legal ground for foreign troops’ presence in Afghanistan, currently remain in force until at least the end of 2024. Nor is it clear if non-NATO forces, from Australia to Georgia, would follow the U.S. withdrawal schedule.

The Afghan government also seems uncomfortable about the U.S. pledge to release 13,000 Taliban prisoners within three months of the announcement of the deal. Finally, the fact that the draft agreements make no mention of the September presidential elections has created impressions among Afghans that polls will be shelved. As a result, some candidates are likely to boycott the vote, while others are hardly campaigning.

Despite these flaws, the U.S.-Taliban agreement could serve as a stepping stone to starting direct negotiations between the Afghan government and the Taliban. The intra-Afghan negotiations, facilitated by Norway and tentatively scheduled for mid-August, are expected to lead the two sides to a compact on the main political issues, including Afghanistan’s political future. A 15-member Afghan negotiating team has already been formed to engage in the talks.

To ensure its withdrawal does not jeopardize Afghan peace, the United States should work to address concerns with the deal at this critical moment. First, it should condition its final withdrawal date on full and verifiable implementation of the eventual intra-Afghan agreement, and should engage with the U.N. Security Council to endorse the final deal, a move that would provide a legal basis for the agreement and ensure compliance.

It should also exercise caution while releasing Taliban prisoners to ensure that those freed do not defy the agreement and join terrorist ranks, including those of the Islamic State. Given that there are nearly 10,000 active foreign fighters in Afghanistan, including some with combat experience in Iraq and Syria, it is imperative that the United States maintain a modest counterterrorism force in Afghanistan while maintaining training and financial support to government-aligned Afghan security forces.

Finally, a U.S.-facilitated dialogue between Afghanistan and Pakistan should be convened, allowing the two countries to negotiate bilateral arrangements that would help ensure the deals with the Taliban stick.

Make no mistake: Peace requires talking, and talking takes time. The United States should work to make sure it is on the right side of any agreement with the Taliban. A ramshackle deal among the Afghan elites will only result in more uncertainty — and could even tip Afghanistan over the edge to becoming a failed state.

Read more: