Warning: this article contains the name of an Aboriginal person who has died.
Cleveland Dodd was found unresponsive inside a cell in the trouble-plagued youth wing of a high-security adult prison in the early hours of October 12, 2023.
The Yamatji teenager was taken to hospital in a critical condition and died a week later, causing outrage and grief in the community.
Former director general of the Department of Justice, Adam Tomison, addressed Cleveland's family from the witness box.
"I'm truly sorry that what happened with Cleveland," he said on Wednesday.
He said it was a "total tragedy" and he and the department had failed.
"I'm extremely sorry ... I wish it didn't happen. I wish I could take it back but I can't."
Under questioning from Coroner Philip Urquhart and Counsel assisting Anthony Crocker, Dr Tomison agreed Cleveland's death was preventable and predictable.
"There was self-harming behaviours in that unit and they were occurring on way too frequent a basis," he told the Perth court on Wednesday.
"So in that sense ... yes, potentially a predictable outcome."
Dr Tomison agreed that under his leadership there were staffing issues at Unit 18 at Casuarina Prison and the Banksia Bill Youth Detention Centre.
"I do think we could have done better," he said.
He agreed there was not an adequate model of care for detainees, many of who were vulnerable Indigenous children from impoverished backgrounds.
Asked about the changes at the sites, Dr Tomison agreed the focus had been on bolstering security and not improving the therapy and welfare provided to detainees.
He said the much-criticised situation at the facilities over the past few years could have been improved if the department had not overused "oppressive" lockdowns to manage detainees in the face of staff shortages.
He concurred the department had acted unlawfully by confining detainees to their cells for long periods despite being aware of two Supreme Court judgements that found it had.
"It took too long," he said in response to questions about the department's efforts to change its policy to a lawful model.
The inquest continues on Thursday with more testimony from Dr Tomison.