I would simply clean the area around the rubber diaphragm in your fill valve, especially any "plug" you see that fits snugly into a hole. If it's a Fluidmaster fill valve, your rubber diaphragm just needs cleaning or replacement.
You see, the way toilet fill valves work is the same as the water fill valve on washing machines and dish washers. There is a rubber diaphragm inside the fill valve that has city water pressure acting on both sides of it. Since the area over which that pressure acts is larger on one side of the diphragm than the other, (And Force = Pressure X Area) there is a greater force pushing on the large area side than the small area side, and that net force in one direction is what keeps the rubber diaphragm tightly sealed over an opening that allows water to flow into the toilet tank.
When you flush the toilet, (or turn on your clothes washer or dish washer). a plug is pulled out of the large area side, releasing the pressure on that side and allowing the city water pressure acting on the small area side to push the diaphragm open and allow water to flow under it into the tank (or spin basket).
Most likely, all that has happened is that some dirt has gotten into the area around that plug and is allowing the water pressure on the large area side to gradually escape, so that the valve continuously opens and closes by itself. Or, the rubber around the plug may have been scratched by that dirt and so the whole rubber diaphragm needs to be replaced.
This method of controlling water flow is extremely reliable, which is why every toilet fill valve uses it. The difference between fill valves lies mostly in the mechanisms they use to move that plug on the large area side of the diaphragm. However it's strictly an ON/OFF control system, so it's not used in faucets where you need to vary the relative amounts of hot and cold water to get a comfortable temperature. It is used on clothes washers where your only options are hot, cold and warm. In that case only the hot solenoid, cold solenoid or both solenoids are energized.
Also, this kind of water control system is very susceptible to dirt. To work properly, you need a good seal on the small area side of the diaphragm and around that plug. Dirt getting into either of those two areas will affect the operation of the closure system.