After upgrading my TFS 2010 installation from Beta 2 to RTM I noticed that my build agent stopped working. I also noticed that I was unable to delete the build agent with an error message along the lines of "Cannot remove build agent [agent name] from build controller because it is currently reserved for a build".
I'm pleased to announce that I finally figured out how to resolve the issue.
In SQL Server Management Studio connect to your team project collection db (tfs_[collection name].
Execute the following SQL statement:
SELECT * FROM tbl_BuildAgent
Locate the build agent in question then note the value of ReservationId and AgentId.
Execute the following SQL statements:
DELETE FROM tbl_BuildAgentReservation WHERE ReservationId = [ReservationId]
UPDATE tbl_BuildAgent SET ReservationId = NULL WHERE AgentId = [AgentId].
Once that was done I was able to successfully remove the Build Agent from TFS Admin Console.