MIDDLETOWN, N.Y. — The director of the public library in this Hudson Valley town calls his assistant and security guard “Starsky and Hutch.” They have been trained to spot signs of overdose in library patrons — paleness and shortness of breath when it is heroin; sudden collapse when it is fentanyl — and administer the drug naloxone. They patrol the bathrooms and stacks at the Middletown Thrall Library, checking on anyone who is dozing.

“It’s easier to call the police, to wait for E.M.S.,” said the library director, Matt Pfisterer, who had to decide whether to use the overdose-reversing drug himself a few years ago, after he found a woman lying in the grass outside, unconscious and covered with ants.

“You don’t know how they’re going to react,” he said. “But when it comes down to it, you ask, ‘Do I want to see this person dying in front of me?’ ‘No.’ So you take the leap.”

The opioid epidemic is reshaping life in America, including at the local public library, where librarians are considering whether to carry naloxone to battle overdoses. At a time when the public is debating arming teachers, it is another example of an unlikely group being enlisted to fight a national crisis.