For years they were children at war, boys given rifles and training by al-Qaeda-backed militants and sent to the front lines of Somalia's bloody conflict.
Many had been kidnapped from schools and soccer fields and forced to fight.
The United Nations pleaded for them to be removed from the battlefield. The United States denounced the Islamist militants for using children to plant bombs and carry out assassinations.
But when the boys were finally disarmed - some defecting and others apprehended - what awaited them was yet another dangerous role in the war. This time, the children say, they were forced to work for the Somali Government.
The boys were used for years as informants by the country's National Intelligence and Security Agency (NISA), according to interviews with the children and Somali and UN officials.
The faces of intelligence agents were covered, but the boys - some as young as 10 - were rarely concealed, according to the children. Several of them were killed. One tried to hang himself while in custody.They were marched through neighbourhoods where al-Shabaab insurgents were hiding and told to point out their former comrades.
The Somali agency's widespread use of child informants, which has not been previously documented, appears to be a flagrant violation of international law. It raises difficult questions for the US Government, which for years has provided substantial funding and training to the Somali agency through the CIA, according to current and former US officials.
A CIA spokesman declined to comment on the issue. But in the past the US Government has supported Somali security institutions - despite well-known human-rights violations - citing the urgent need to combat terrorist groups such as al-Shabaab.
The child informants were used to collect intelligence or identify suspects in some of the world's most dangerous neighbourhoods, according to their accounts.
"They took me sometimes in a car and sometimes on foot and said, 'Tell us who is al-Shabaab," said one 15-year-old who said he was held by the intelligence agency. "It's scary because you know everyone can see you working with them."
The teenager was one of eight boys interviewed by the Washington Post who described being forced to work as informants after leaving al-Shabaab. The boys each spoke alone, through an interpreter, but their accounts were nearly identical.
They said that they spent years in the custody of intelligence agents and were dragged along on missions, sometimes several times a week. Occasionally, they were told to wear NISA uniforms. They were threatened with violence if they didn't cooperate, several boys said. Their parents didn't know where they were.
Somali intelligence agents called the boys "far-muuq," they said - finger-pointers.
Somalia's Army has long recruited children as soldiers. But for years, UN and human-rights officials found it difficult to confirm reports about a shadowy government-run centre in Mogadishu, which was said to hold children used in intelligence operations.
Only late last year did UN officials convince Somali authorities to transfer the boys to a new rehabilitation centre, where they would not be accessible to intelligence agents, according to UN and Somali officials. That is where The Post interviewed the children.
Somalia's intelligence chief denied in an interview that the boys were forced to work as informants, but said that "high-level" child combatants were - and still are - kept in custody, both because they are dangerous and have valuable knowledge.
Those boys, he said, sometimes volunteer to go on missions, and have yielded "important information" that has helped agents prevent future attacks.
"If a child joins al-Shabaab when he is 9, by the time he is 16, he is a lion," said NISA's director, General Abdirahman Turyare, in an interview. "They are able to point to someone and tell us, 'That guy, he fought with me.' "
Somalia's intelligence agency continues to keep such boys for months at a time, Turyare acknowledged, in spite of a 2014 agreement to release children to Unicef within 72 hours of their escaping al-Shabaab or being apprehended.
Although details of the CIA's operations in Somalia are secret, Somali officials said the two agencies work together closely.
"There's nothing NISA does that the CIA doesn't know about," said a senior Somali official.
During Somalia's 25-year civil war, which has shifted among rebel factions, clans and Islamist groups and left hundreds of thousands dead, children have constantly been caught up in the fighting.
The country's military has long enlisted boys to fight; in 2015, Unicef recorded more than 300 cases of children being used as soldiers by Somali forces. That practice would normally trigger a US ban on most military aid, but President Barack Obama has granted Somalia a waiver on national-security grounds in recent years.
Al-Shabaab, which seeks to transform the country into a hard-line Islamic state, has been even more notorious for recruiting children. In some parts of Somalia, the group has ransacked classrooms, kidnapping hundreds of children and sending them to training camps.
The international community, recognising that child combatants needed to be assimilated back into Somali society, lobbied in recent years for a reintegration programme. And the Government in 2012 launched a plan that it said would provide former underage soldiers with psychological help and education.
But according to the boys interviewed in Mogadishu, the programme they entered was not about rehabilitation. To their surprise, the teens were put to work gathering intelligence.
"Maybe they thought because we were young we would be easier to manipulate," said one baby-faced 15-year-old who goes by the nickname Yariso, or "Shorty."
The boys became such fixtures in Somali security operations that witnesses began alerting local humanitarian groups, asking, "Who are these children with NISA?"
In late 2015, after years of pressure from the United Nations, the children were quietly transferred from the government-run detention centre to a juvenile rehabilitation facility in central Mogadishu at the Elman Peace and Human Rights Centre, which is run by a nonprofit group and receives its funding from Unicef. Thirty-three of the boys remain. Thirty-one have been released.
But international aid workers and experts suspect that the use of boys as informants continues.
One Somali security official confirmed that "hundreds" of children remain in NISA facilities and are used as intelligence assets.
In Galkayo, in central Somalia, about 30 former child combatants have been kept in a one-room building since being captured in late March, and have faced NISA interrogations, according to several relief workers.
In 2015, Somalia ratified the UN Convention on the Rights of the Child, which outlaws the recruitment of children younger than 15 by security forces. Such recruitment is considered a war crime by the International Criminal Court. The majority of the former underage soldiers interviewed by the Post said they began working as informants before they turned 15.
Turyare, the intelligence chief, shrugged off humanitarian groups' concerns.
"The angle (Unicef) is responsible for and the angle we are responsible for is different," he said.
"The angle (Unicef) is responsible for and the angle we are responsible for is different," he said.
Other officials said the distinction between child and adult combatants is blurrier in Somalia than in Western countries. For example, in Puntland, a large, semiautonomous region in northern Somalia, the state constitution says anyone older than 14 is considered an adult.
"Here we consider the body, not the age," said Major General Mohamed Sheikkh Hamud, Somalia's police commissioner and former head of intelligence.