Seems the problem is its running too rich, and only when it runs out of fuel, and finally leans out some, it increases in rpm.
You have some good advice, so work thru it step by step.
My advice, is to check whats already been mentioned, if your not sure how to check each thing, then ask.
if its got some hours on it, when was the last time it had a carb kit in it. ?
could be some leaking fuel past the needle, running too rich, stiff metering diaphragm usually causes other issues, but hey, could be an issue here.
The fuel pump diaphragm and its one way valves can go stiff in operation, or not seal over the body of the carb on the drillings, all can contribute to it.
would suggest getting a new carb kit go gen stihl, and fuel filter whilst your there, and go from there.
Have a good look inside, make sure the needle seat is not scored, or dirty with dried up/ fuel resin, which can also contribute to a needle not sealing well.
Lets go step by step thru this and fix it.