WASHINGTON - CIA officers in Iraq have been largely hunkered down in their heavily fortified Baghdad compound since U.S. troops left the country in 2011, current and former officials say, allowing a once-rich network of intelligence sources to wither.

That's a big reason, they say, the U.S. was caught flat-footed by the recent offensive by a Sunni-backed al Qaeda-inspired group that has seized a large swath of Iraq.

"This is a glaring example of the erosion of our street craft and our trade craft and our capability to operate in a hard place," said John Maguire, who helped run CIA operations in Iraq in 2004. "The U.S. taxpayer is not getting their money's worth."

Get Breaking News Delivered to Your Inbox

Maguire was a CIA officer in Beirut in the late 1980s during that country's bloody civil war. He spent weeks living in safe houses far from the U.S. Embassy, dodging militants who wanted to kidnap and kill Americans. In Iraq, where Maguire also served, the CIA's Baghdad station remains one of the world's largest. But the agency has been unwilling to risk sending Americans out regularly to recruit and meet informants.

Iraq is emblematic of how a security-conscious CIA is finding it difficult to spy aggressively in dangerous environments without military protection, Maguire and other current and former U.S. officials say. Intelligence blind spots have left the U.S. behind the curve on fast-moving world events, they say, whether it's disintegration in Iraq, Russia's move into Crimea or the collapse of several governments during the Arab Spring.

Without directly addressing the CIA's posture in Iraq, agency spokesman Dean Boyd noted that 40 officers have died in the line of duty since September 2001. He called "offensive" any suggestion that "CIA officers are sitting behind desks, hiding out in green zones, or otherwise taking it easy back at the embassy."

Boyd said the intelligence community provided plenty of warning to the Obama administration that the insurgent Islamic State in Iraq and the Levant, known as ISIL or ISIS, could move on Iraqi cities.

"Anyone who has had access to and actually read the full extent of CIA intelligence products on ISIL and Iraq should not have been surprised by the current situation," he said.

Rep. Mike Rogers, R-Mich., the chairman of the House intelligence committee, agreed, saying, "This was not an intelligence failure - this was a policy failure."

However, while U.S. intelligence officials predicted that ISIL would attempt to seize territory in Iraq this year, they did not appear to anticipate ISIL's offensive on June 10 to seize Mosul, which created a momentum that led to other successes. Officials also expressed surprise at how quickly the Iraqi army collapsed. And military leaders contemplating quick airstrikes said there was not enough intelligence to know what to hit.

A senior U.S. intelligence official who briefed reporters this week acknowledged that "a lot of the (intelligence) collection that we were receiving diminished significantly following the U.S. withdrawal in Iraq in 2011, when we lost some of the 'boots on the ground' view of what was going on." Under rules for such briefings, the official spoke on condition that her name not be used.

In the same briefing, the official disclosed that U.S. intelligence did not know who controlled Iraq's largest oil refinery. And she suggested that one of the biggest sources of intelligence for American analysts is Facebook and Twitter postings.

The U.S. spent nearly $72 billion on intelligence gathering in 2013.

It was telling that President Barack Obama sent 300 special operations troops "to help us gain more intelligence and more information about what ISIL is doing and how they're doing it," Pentagon spokesman John Kirby said - an implicit admission that American intelligence-gathering about ISIL has been insufficient.

No one suggests that the CIA carries all the blame. After American troops left Iraq, the State Department abandoned plans for a huge diplomatic staff at a network of facilities.

Kevin Carroll, a former CIA operations officer with Middle East experience, said it's unreasonable to expect the agency to collect "from a fortified war zone embassy the breadth and depth of information collected when U.S. military bases and troops throughout Iraq helped support CIA operations."

But for Maguire and other former intelligence officials, it's clear the CIA has allowed its espionage muscles to atrophy.

CIA officers lived in well-guarded bases all over Iraq during the U.S. occupation, and met frequently with Iraqis. But even then, it wasn't traditional spying. Often, agency operatives would travel to meet sources in highly visible armed convoys. They knew that the U.S. military was somewhere over the horizon if things went wrong. And security concerns often left case officers confined to their bases, several former CIA officers said.

The agency operates the same way in Afghanistan, where it is also closing a series of remote bases as the U.S. troop presence there draws down. Intelligence collection there is expected to suffer as well.

The CIA's approach is designed, current and former officials say, to prevent the sort of thing that happened in 1984, when Beirut station chief William Buckley was kidnapped from his apartment by Hezbollah and tortured to death. But bases can also be attacked, as in 2012 in Benghazi, Libya, when two CIA contractors were among four dead Americans.

Other intelligence services accept more risk. In Israel's Mossad intelligence agency, most case officers operate outside of embassies, posing as civilians under what the U.S. calls "non official cover," said Ronen Bergman, who covers intelligence affairs for Israeli daily Yedioth Ahronoth and is working on a history of the Mossad.

In countries such as Iran where Israel does not have an embassy, the Mossad sends deep cover operatives to live and gather intelligence, knowing they could be executed if discovered, Bergman said.

But Israel can call upon a large population of native Arabic speakers whose appearance allows them to blend in. U.S. intelligence leaders have been talking for years about the need to recruit non-white case officers and train them in difficult languages, but current and former officials say it just hasn't happened at the level anticipated after 9/11.

The intelligence budget document leaked last year by Edward Snowden shows that after 11 years of war in Afghanistan, just 88 people in civilian U.S. intelligence agencies got bonuses for speaking Pashto, the language of the Taliban and its allies.