Handles

"" was the name given by the Eleventh Doctor to a Cyberman head that he had obtained from the Maldovarium Market, and subsequently repaired. All of its organic components and Cyberman protocols had been cleaned out, leaving it a plain, docile robot that interpreted commands literally, whether or not they were meant to be taken as rhetorical statements. It went on many adventures with him as he searched the mysterious planet of Trenzalore. When the Doctor went aboard ships orbiting Trenzalore before he gained access, Handles was accidentally brought aboard a Cyber-Ship, which led the Cybermen to attack the Doctor.

Outliving the residents he had chosen to protect, Handles was the Doctor's only companion during his first three hundred years in Christmas. (TV: The Time of the Doctor)

The Doctor left Handles behind when he stopped the Krynoids from spreading across Trenzalore. He spoke with Handles about happiness after he had defeated the Krynoid during the harvest festival in Christmas. (PROSE: An Apple a Day)

As the years passed, Handles began to corrode with rust and slowly lost his functionality. The Doctor kept repairing Handles as best he could, but he lacked enough spare parts and it eventually broke down. Before shutting down, Handles finally fulfilled an order the Doctor had given it prior to landing on Trenzalore: reminding the Doctor to patch the TARDIS phone back to the console. Handles' death reduced the Doctor to tears. (TV: The Time of the Doctor)

In his delirious post-regenerative condition, the Twelfth Doctor briefly believed Handles had regenerated into Clara Oswald. (TV: Deep Breath)

Behind the scenes
Depending on views of the TARDIS's sentience, Handles is the longest-serving companion, in terms of time, the Doctor has had, as he was with him for the first 300 years he was on Trenzalore.