Describe the task you're waiting for as text, and let an LLM pick the number of seconds for each request. More expensive the better model you clearly need for this. There, your AI pitch.
Retries won’t work in that case. Would be better to have two endpoints: get the time in x seconds and wait until time passed. That way retrying the wait endpoint will work fine and if time hasn’t elapsed it can just curl itself with the same arguments.
If you have curl (but not sleep) sure, but if not maybe you can use bash's wacky /dev/tcp. The microservice could listen on ports 1 through 64k to let you specify how many seconds to sleep.
Maybe a more serious fix is something like "read -t $N". If you think stdin might not be usable (like maybe it will close prematurely) this option won't work, but maybe you can open an anonymous FD and read from it instead.
while (time() != timeout) {;}
The fixed loop is:
while (time() < timeout) {;}