Normally an AppleScript waits. It will execute the commands, functions, whatnot, in order, not asynchronously. Of course, there may be some glitches when external things are involved, like saving a huge file to disk.
But in AppleScript you also have the dalay command, similar to the Pause action in KM. Try to place it on different locations in the script and see if it changes something. If you think it is a timing issue.
This is also often called “isolating the issue”. (Not exactly the same, but pretty much.)
Strip off as many actions as possible from your macro until the issue disappears (or the core functionality of the macro stops working).
I know, in your case it is probably (but not definitly) related to the AppleScript. Do the same as said above in addition with the AppleScript: Strip off as many functions, variables, lines as possible until the issue stops appearing — or the core functions of the script stop working.
Just try to remove as much as possible: any secondary features, anything that isn’t essential (in terms of script mechanics), while still being able to produce the issue.
Then post the stripped down script and macro. This will greatly help to get a solution.
Besides that, it often happens that in the process of building a minimal example (i.e. trying to isolate the thing) the issue suddenly becomes obvious “like the shining sun” [replace this with a good idiomatic expression]. I have experienced this countless times.
I’m not saying this to say something, it’s a serious recommendation that may help you to get a solution until Thursday. I will try to help you maybe tomorrow or Thursday afternoon, but if you could already do some “preparation work” (i.e. trying to isolate the issue or build a Minimal Example), we have better chances.
For example, inside the whole “eval” stuff (we have 3 of them), remove everything but the obligatory one(s). If in the process of doing that you notice that the issue has went away, you have made a major leap towards a working script.