I've been experiencing this issue for a few months now and was hoping somebody could help me out

hopefully I won't need a new transmission
My 1983 300d turbo has about 300,000 miles on it, and since I got it with 277k miles on it, it always had this little flare/hesitation at the top of 2nd/3rd gear but it seemed to go away once the engine warmed up and i figured it's probably normal
Now, it has progressed into a slightly more worrisome issue
Instead of a little flare, the engine RPM will start revving up and down for 3-4 seconds quite fast, before shifting to the next gear. It's not a violent shake or anything but it's quite noticeable and definitely more pronounced than before. It's acting like somebody is pushing and release the gas pedal a little bit every half-second
This also seems to go away when the engine gets warm.
Would this be an issue with the engine? Or is the automatic transmission failing?
I would appreciate any advice you guys can throw my way