Sounds like a water temp senser...This senser tells the engine how to run when cold and hot...If it is bad one of 2 things will happen, it reads the engine is operating in cold winter enviroment, or its hot and operating in a hot enviroment. When the senser dies it will die in one of these positions, yours has died in the hot position, and starves the engine of fuel and possibly advances the timeng and runs bad till it is warmed up which is the better of the 2 ways it could go...
The senser is under $20.00 and is right in the front of the engine, very easy fix