If the function works, you must have an error with this part:

execute as @e[tag=robot] if block ~ ~-1 ~ air run

A multitude of problems could be causing this. In addition to the obvious (make sure there is an entity tagged robot, make sure the block under the robot is air, etc.), the most likely issue is that the function is not being ran at the robot. Instead, the if block ~ ~-1 ~ air check is run at the location the command was executed (at your player, or at a command block, whichever you are using).