KABUL, Afghanistan — As the United States appears to be nearing a deal with the Taliban on pulling its troops from Afghanistan, the country’s security forces are in their worst state in years — almost completely on the defensive in much of the country, according to local military commanders and civilian officials.

Afghan commanders vowed last year to take the offensive, rather than go on fighting a static “checkpoint war.” But in most major battlegrounds, the bulk of the regular Afghan forces are still holed up in fortified bases and outposts. Most offensive operations have been left to small numbers of Afghan and American Special Operations soldiers, backed by both countries’ air forces.

The woeful state of the regular Afghan forces has been widely seen as giving the Taliban a valuable edge in its negotiations with the United States, which have gone on for eight rounds in Doha, Qatar, and are believed to be near a conclusion. An announcement could come as early as Tuesday but also may be delayed, perhaps for weeks.

An analysis of more than 2,300 combat deaths of government forces, compiled in daily casualty reports by The New York Times from January through July, found that more than 87 percent occurred during Taliban attacks on bases, checkpoints or command centers. These numbers indicate that the Taliban can attack many such bases almost at will.