Recently I've noticed that my build agent stopped working for no reason.
Also, I noticed that I was unable to delete the build agent with the following error message:
"Cannot remove build agent [my build agent] from build controller because it is currently reserved for a build".
I tried to delete every single item from the build queue, but it didn't worked.
Finally I figured out that the only way to solve that problem was by deleting the build entries directly on TFS database.
I connected to my team project collection db (tfs_[collection name]), and then executed the following SQL statement:
SELECT * FROM tbl_BuildAgent
I found the build agent that wasn't working properly.
I executed the following SQL statements:
WHERE ReservationId = [ReservationId]
WHERE ControllerId = [ControllerId]
SET ReservationId = NULL
WHERE AgentId = [AgentId]
That's it. Now it's working properly.