WASHINGTON — After a week of oversights and failures, the officers protecting former President Donald Trump at a campaign rally in Butler, Pennsylvania, still had one last chance to get it right. The chance lasted about 30 seconds.

It began when a local police officer peered over the roof of the AGR International warehouse near the rally grounds and found the suspicious man he and other officers were hunting. Ninety minutes of confusion about Thomas Crooks’ intentions and whereabouts had ended in an instant.

“Long gun!” the officer broadcast over the local law enforcement radio system, according to congressional testimony from the Secret Service this week.

It was urgent news that should have instantly traveled to a command center shared by the local police and the Secret Service, and then to agents close enough to throw their bodies in front of Trump. They still had time to disrupt an assassination attempt.

But the radio message never got to the Secret Service, and 30 seconds later Crooks unleashed his first shots.

That dropped communication was one of several instances in which technologies that might have protected Trump from getting shot July 13 did not — either because they malfunctioned, were improperly deployed or the Secret Service decided not to use them in the first place.

The Secret Service, for instance, turned down offers to use a surveillance drone at the Butler Farm Show rally site. The agency also did not bring a system to boost the agents’ device signals in an area with poor cellular service. And some of the equipment the agency did bring, including a system to detect drone use by others, did not work when it was most needed.

The result was that a 20-year-old gunman had a technological advantage over a $3 billion federal agency.

The acting Secret Service director, Ronald Rowe Jr., told Senate lawmakers in a hearing this week that the agency had the tools that could have spotted Crooks and allowed agents to interrogate him before the shooting, but failed to properly use them.

“That has cost me a lot of sleep,” Rowe testified. “It is something that I have struggled with to understand, and I have no — I have no explanation for it.”

Trump was injured in the shooting, as were three rally attendees, one fatally, in one of the biggest failures of the Secret Service in decades. Rowe, in his testimony, said that he could not understand why the Secret Service chose to exclude the warehouse Crooks used, about 450 feet from Trump’s lectern, from its secure perimeter and why no countersniper was assigned to its roof.

But the problems were more than strategic errors on how to use law enforcement personnel. Current and former Secret Service and federal government officials, in interviews, acknowledged that the agency has long struggled to rapidly incorporate technology that could assist in its mission.

“We are living in 2024,” said Mike Matranga, a former Secret Service officer who now runs his own security firm that helps protect many schools and businesses with policing tools. “Why is the government the last one to be able to develop and deliver technology to their advantage?”

The presence of technology itself does not guarantee a protectee’s safety, but it can provide a vital backstop in an era of heightened polarization and overt political violence. And it is even more important when the Secret Service staff is stretched thin due to the intense demands of a presidential election.

Government audits dating back decades have criticized the Secret Service for the slow embrace of technology, as it appears to be reliant on a 1950s model of armed agents using their own weapons and, if necessary, bodies to protect presidents and other high-profile figures.

Nine years ago, after gunshots were fired near the home of Vice President Joe Biden, Jason Chaffetz, who served that year as the chair of the House Oversight Committee, immediately asked to view the footage.

But the Secret Service director at the time showed up to a meeting with Chaffetz empty-handed.

“He sheepishly came in and said, ‘We don’t have cameras,’” Chaffetz said in an interview. Chaffetz’s committee issued a scathing report that year, saying the agency was in urgent need of reform.

Money, or at least how it is allocated, has been a factor. Congress has steadily increased the Secret Service budget over the past decade to $3.1 billion this year from about $2.3 billion in 2014, in inflation-adjusted dollars.

But budget documents show the agency spends only about $4 million a year, less than 1% of its funding, on research and development for new security tools and other needs. For next year, the agency actually asked Congress to provide much less funding for research — only $2.2 million.

The Secret Service did not respond to questions about its spending on security technology.

It can take years for the agency to evaluate new technology and get clearance and funding to acquire it, and even longer to train personnel on how to use it, said Chris DeMunbrun, a former Secret Service officer who resigned in 2017 after growing frustrated with the agency’s lack of progress on embracing new tools.

In addition, civil liberties concerns have prevented the agency from broadly deploying facial recognition software, though it is commonly used at private venues like casinos.

The software could help the agency rapidly identify individuals who are known threats.