How does a thermos know?

A thermos keeps hot things hot and cold things cold.

Thermos Brain

But how does it know?