Likely Variant by Robison Wells. Published in 2011, which fits you having read it about 5 years ago.
From Goodreads:
Benson Fisher thought that a scholarship to Maxfield Academy would be the ticket out of his dead-end life.
He was wrong.
Now he’s trapped in a school that’s surrounded by a razor-wire fence. A school where video cameras monitor his every move. Where there are no adults. Where the kids have split into groups in order to survive.
Where breaking the rules equals death.
But when Benson stumbles upon the school’s real secret, he realizes that playing by the rules could spell a fate worse than death, and that escape—his only real hope for survival—may be impossible.
And from Wikipedia:
Some few hours later that night, Benson wakes up and tries to wake Jane. Jane twitches, and afterward systematically walks to a door on the wall around the school. The door leads to a basement, with computers and labs. She walks to a computer, pulls off her ear and plugs a cable from the computer into her head. From this Benson learns that Jane, and possibly others, are not human, but androids. With no adults obviously present, it is everyone for themselves. The students are supervised by unknown people, communicating by videos and messages, but never in person.
Found with the Google query science fiction book school prison robots site:goodreads.com/book
.