Well it sounds like it isn't getting gas! Maybe fuel filter clogged, and if that isn't it then you need to clean up the carb. I assume you didn't adjust anything recently? What brand of equipment are we talking about?
Is the throttle working correctly? It isn't jammed or stuck? On most small 2-cycle engines the fuel filter is on the end of the fuel line inside the gas tank. You need to get a wire, make a hook at the end, and fish it out (if you already knew this, sorry!).
Does the unit seem like it has good compression? Maybe pull the exhaust and check to see that ports are clean and condition of the rings. If that is okay check to see if the cranshaft seals are okay starting with the rope side starter. Are you sure that the fuel lines coming from tank didn't get switched?
Well it looks like it could be a couple issues with this machine. The firs tthat comes to mind is a possible air leak. The wide open then shutting down take what should be a rich mixture and leans it out unti lthe point you have more air than fuel and it shuts down. Air leaks can be caused by manyb things. Fuel lines with pin holes, loose carb, bad manifold gasket, loose cylinder (ryobi is famous for this) sucking air in from the cylinder base gasket.
Lookfor the simple and obvious first. This is usually where you find your troubles.
If you do not have an air leak then the next thing in my mid is that you are running our of fuel. You can force fuel into the system by priming it then it runs dry. This problem usually does not manifest itself as running full throttle though. If this is the case check fuel filter and carb.