PARKLAND, Fla. — A Florida social services agency conducted an in-home investigation of Nikolas Cruz after he exhibited troubling behavior nearly a year and a half before he shot and killed 17 people at his former high school in Florida, a state report shows.

The Florida Department of Children and Families had been alerted to posts on Snapchat of Cruz cutting both his arms and expressing interest in buying a gun, according to the report. After visiting and questioning Cruz at his home, the department determined he was at low risk of harming himself or others.

The report is the latest indication that Cruz was repeatedly identified by local and federal agencies as a troubled young man with violent tendencies.

The FBI acknowledged Friday that it had failed to investigate a tip called into a tip line last month by a person close to Cruz identifying him as a gun owner intent on killing people, possibly at a school.

A person close to Cruz called the tip line on Jan. 5 and provided information about Cruz’s weapons and his erratic behavior, including his disturbing social media posts. The bureau acknowledged that the tip should have been shared with the FBI’s Miami office and investigated, but it was not.

The police were called to Cruz’s house many times for disturbances over several years.

Cruz also worried officials at his former school, Marjory Stoneman Douglas High in Parkland, who on at least one occasion alerted a mobile crisis unit to get him emergency counseling, according to the state report.

Howard Finkelstein, the Broward County public defender, whose office is representing Cruz, said the report was further evidence that Cruz needed serious help long before the shooting, but did not get enough of it.

“This kid exhibited every single known red flag, from cutting animals, to having a cache of weapons, to disruptive behavior, to saying he wanted to be a school shooter,” Finkelstein said. “If this isn’t a person who should have gotten someone’s attention, I don’t know who is. This was a multisystem failure.”

The Department of Children and Families investigated whether Cruz intended to harm himself in September 2016, when he made the alarming social media posts after an argument with his mother.

Cruz, who had depression, was upset over a breakup with a girlfriend, his mother, Lynda Cruz, told investigators. The report does not say who called in the complaint.

But the Department of Children and Families report shows that investigators closed the case because they found Cruz was being taken care of by his mother and was receiving mental health counseling.

The investigator determined that the “final level of risk is low,” an analysis that even one of Cruz’s counselors at his school felt was premature.

On Wednesday, Cruz, now 19, showed up at Stoneman Douglas High School in Parkland and unleashed more than 100 rounds from a semiautomatic AR-15 rifle he purchased in February 2017, five months after the state investigation closed.

The investigation, first reported by The South Florida Sun Sentinel on Friday, was obtained by The New York Times on Saturday. The state agency had petitioned a court Friday to make the confidential records public, but the court has yet to do so.

“Based on the information at this time, this individual had no involvement with Florida’s child welfare system, including foster care,” said Jessica Sims, a spokeswoman for the Department of Children and Families.

Cruz was investigated as an adult, and the investigation appeared aimed at determining whether he was being neglected.

Agency investigators identified Cruz, who had just turned 18 a few days earlier, as a “vulnerable adult due to mental illness.”

Cruz was depressed and had autism and attention-deficit hyperactivity disorder, the report said. He was regularly taking medication for the ADHD. It was unclear whether he was taking anything for the depression, according to the report.

After the argument with his mother, an investigator visited the family’s home in Parkland, which was clean, clutter-free, and did not present any foul odors. The investigator did not see the cuts on Cruz’s arms: He was wearing long sleeves.

“Mr. Cruz stated that he plans to go out and buy a gun,” the report states. “It is unknown what he is buying the gun for.”

His mother, who died in November, told investigators she attributed Cruz’s behavior to “a breakup with a girl.”

Cruz “stated that she and the girl’s mother told the kids they had to end the relationship because it was unhealthy for everyone,” the report said.