But General Mark Milly said it was "possible" for the United States to coordinate with Islamic militants on future counter-terrorism operations.
U.S. troops withdrew from Afghanistan Tuesday, ending the longest U.S. war in 20 years after launching an invasion to topple the Taliban.
Islamists now control and are expected to announce a new government.
Milley was speaking alongside US Defense Secretary Lloyd Austin in his first public remarks since the latter left Afghanistan.
President Joe Biden has been widely criticized for the sudden way of withdrawing, which led to the unexpected collapse of U.S.-trained and funded Afghan security forces for years.
The Taliban's lightning advance sparked a frantic attempt to evacuate thousands of foreign nationals and local Afghans who were working for them.
At Wednesday's press conference, General Milley and Minister Austin praised the troops who served in Afghanistan and the massive evacuation mission.
Asked about their cooperation with the Taliban in transporting evacuees to the airport, Austin said: "We've been working with the Taliban on a very narrow set of issues, and that's all - to get as many people out as possible."
"In war, you do what you have to do to reduce the risk to the mission and the force, not what you necessarily want to do," Heli said.
He said the United States is likely to coordinate with the Taliban on future action against the Islamic State group, which claimed an attack outside Kabul airport last week that killed up to 170 people, including 13 U.S. troops.
IS is the most extreme and violent of all armed jihadist groups in Afghanistan. It has major differences with the Taliban, accusing it of abandoning jihad and the battlefield.
At the same time, Mr. Austin said that he "does not want to make any predictions" about future cooperation. But he added that officials "will do everything we can to make sure that we remain focused on [ISIS-K], understand that network, and at the time we choose it in the future, hold them accountable for what they have done."
In total, the evacuation saw more than 123,000 people wishing to flee the Taliban airlifted out of the country.
The United States estimates that between 100 and 200 Americans are still in Afghanistan.
Us Under Secretary of State for Political Affairs Victoria Nuland said "all possible options" were being discussed to get the remaining US citizens and people who had worked with the United States out of the country.
Meanwhile, British Foreign Secretary Dominic Raab said he was unsure how many UK citizens remained in the country, but believed their number was "in the low hundreds."
The Taliban have celebrated the final withdrawal of foreign forces and are now focusing on forming a government.
Sher Abbas Stanekza, deputy head of the Taliban's political bureau in Qatar, told the BBC that a new government could be announced in the next two days.
There would be a role for women at lower levels but not in senior positions.
He also said those who have served in the government over the past two decades will not be included.
This magic word "comprehensive" is used by Afghanistan's neighbors to try to pressure the Taliban to share some power so that they do not have absolute control.
But look at it in purely political terms. The Taliban came to power much faster than they had expected. They feel that they have an overwhelming mandate to achieve their ultimate goal of establishing an Islamic regime.
In this new emerging Islamic emirate, women will play secondary roles for men in Afghanistan.
This is very different from what we heard even two years ago when the Taliban began discussing the matter with representatives of the Afghan Government and civil society. They said at the time that women could play any role in our new Islamic government except for the president or the prime minister. They can be ministers or chief executives.
Now they seem to be backing away from that because what happened in the past is now history. It is a new day for them and a day when the Taliban are responsible.