Before the extra years were added to his sentence and before the trouble that led to them, authorities were warned that a teenage boy with severe cognitive impairments was deteriorating in Darwin's Don Dale youth detention centre and needed help.

Key points: A 17-year-old boy was recently sentenced to an additional four years' jail over a riot in Don Dale in July 2018

A 17-year-old boy was recently sentenced to an additional four years' jail over a riot in Don Dale in July 2018 The ABC has seen letters sent to authorities weeks before the riot, requesting urgent intervention

The ABC has seen letters sent to authorities weeks before the riot, requesting urgent intervention A Supreme Court judge accepted that conditions in the prison contributed to the boy's offending

Legal letters seen by the ABC formally requesting urgent intervention in then-16-year-old Corey's* "outrageous" treatment in the condemned facility were sent to the head of the Territory Families department and the NT Children's Commissioner in June last year.

Legal Aid lawyers told authorities that the teenager — who has foetal alcohol spectrum disorder (FASD) and a history of trauma starting from abandonment in hospital at birth — had been kept in effective isolation, with little fresh air, sunlight and schooling, and had been threatened and assaulted by other boys inside Don Dale.

They were told he was distressed, "very isolated" and his mental health was declining.

The advocates implored the department to immediately reverse Corey's sudden transfer weeks earlier from the crowded Alice Springs youth detention centre, where he was closer to family and his case worker.

But nothing was done and two weeks later the teenager joined in a riot at the centre, during which he set fire to the outside of another detainee's cell.

A few weeks ago, an extra four years were added to Corey's sentence for his actions on the night.

Young detainees have run amok in the centre numerous times since the royal commission recommended its closure. ( ABC News )

The ABC can reveal it was Corey's treatment in Don Dale that helped trigger a class action over conditions in the detention centre that the Northern Territory Government is now settling.

The National Disability Insurance Agency has now also voiced "regret" at not stepping in to help him sooner.

But the admissions of failings come too late — the extra years on his sentence will likely shunt Corey from youth detention into Darwin's adult jail next year.

Aboriginal health executive Olga Havnen described Corey's experience in the system as "a tragedy and a disgrace".

"This is not therapeutic, this is not humane, this is not fair," she said.

Those who have visited Don Dale since the sentencing in July say the teenager — who likes geography and hip hop, speaks four Aboriginal languages and dreamed of becoming a ranger — is feeling "very low".

'Punitive, oppressive' conditions preceded riot

The legal letters seen by the ABC were sent two weeks before the Don Dale tinderbox exploded last July — as it has done sporadically since the youth detention royal commission declared it unfit for accommodating young people and said it should be closed.

An NT Legal Aid lawyer wrote to Territory Families chief executive Ken Davies, warning that the "extremely concerning" conditions facing all detainees were "particularly punitive and oppressive" for Corey.

The letter warned that the transfer from Alice Springs had severed the teenager's face-to-face contact with family and his support network.

Corey was confined to a separate accommodation block after being harassed and assaulted by other boys — the lawyer said he was not getting enough time in fresh air or sunlight.

Understaffing lead to lockdowns and dysfunction at the centre, which has been deemed unfit to house young people. ( ABC News: Jane Bardon )

He was getting schooling on only a "makeshift" basis and mostly via workbook, according to the lawyer, who said it was an "outrageous failing".

It would later emerge that serious understaffing at the centre was trapping detainees in excessive cell lockdowns and forcing the cancellation of programs and appointments — one youth court judge even agreed to bail a young offender on conditions rather than send him to Don Dale that July.

Corey remained in Don Dale and two weeks later a fuse was lit.

A group of detainees was told to prepare to be locked down for the night after dinner at 5:00pm — they refused and over the next three hours smashed dents in the centre's roller door with table legs, sprayed a fire extinguisher into the room where unarmed youth justice officers were holed up, threw eggs at each other and lit small fires on splashes of paint thinner.

Another boy threw some of the thinner on the outside wall of a cell in which another detainee was locked.

Corey lit it on fire and the pair shouted "die motherf***er, die" at the boy inside the cell — the fire did not spread but the boy was choking on smoke and utterly terrified.

After police regained control, the boys were charged with damaging property, making a threat to kill and assault.

A class action was launched a month later, with NT Legal Aid lawyers alleging the Northern Territory Government was breaching its legal duties and causing harm to the young people in its care.

Chief Minister Michael Gunner dismissed the court action as coming "five years too late, against the wrong government".

But the government has since agreed to settle the claim.

The details of the settlement are still confidential but the lawyers were asking for the centres to be shut down if conditions were not improved.

They also argued that the problems with Don Dale would have been addressed sooner if the vast majority of young detainees were not Aboriginal.

'Very disabling' impacts of FASD

It was not until after the riot — and two years after he entered the care of the state — that an assessment revealed Corey has FASD with "very low" mental functioning, on top of his diagnoses for major depression and substance misuse disorder.

The percentage of Don Dale detainees who are Indigenous regularly reaches 100. ( 105.7 ABC Darwin: Emilia Terzon )

That gave him difficulty foreseeing consequences and managing impulses and meant he "may be easily persuaded by antisocial peers", according to the court sentencing remarks from July.

The judge considered it possible Corey's risk of harm to others was "much higher" in Don Dale — he had not engaged in violent offending before he entered the detention system.

But the riot was an "escalation", even if the conditions in the centre explained some of Corey's "recklessness and possibly a level of antagonism" towards Don Dale's operators.

The judge said he could not order Corey's release under supervision because the department was unable to supervise him and there was nowhere else for him to go.

NDIS 'regrets' handling of boy's case

The support available in Don Dale had consisted of a GP and a visiting (young, female, non-Aboriginal) psychologist, with no drug or alcohol treatment available.

In January, lawyers applied to get help for him through the National Disability Insurance Scheme.

But the application — which the agency is meant to process within 21 days — went unanswered for months.

The NT Government is closing the condemned centre, which is housed in an old adult jail. ( ABC News: Mitch Woolnough )

The National Disability Insurance Agency (NDIA) told the ABC in June that state and territory governments are responsible for people with disabilities in the criminal justice system.

But the response changed after an official action on Corey's behalf was lodged with the Administrative Appeals Tribunal.

An agency spokesperson confirmed that Corey's bid for help was then approved in July.

"The NDIA regrets that the individual's experience has not lived up to the standards to which the agency aspires," the spokesperson said.

Youth justice improvements underway: department

The Territory Families department said it could not comment on individual cases.

A spokesperson for children's commissioner Colleen Gwynne referred to the recommendations made in monitoring reports after later inspections of the facilities.

Although neither side will comment on the agreement reached in the class action, the Territory Families department says it has made improvements in line with undertakings published when the settlement was reached in April.

A spokesperson said Aboriginal health organisation Danila Dilba was taking over primary health care in the centre, support services had been "significantly" increased and an FASD component was added to staff induction training.

Olga Havnen, who is the chief executive of Danila Dilba, said Corey had been set up to fail in a system that couldn't help him.

She said the teenager's conviction for property damage to Don Dale was ironic, asking: "Who pays for the damage caused to this young person?"

*A pseudonym has been used.