I can tell you now the AI is not very intelligent, period. It can do basic tasks like driving on a mainline. But the instant you put it in a yard or switching scenario, it is like "wait, what do you want me to do exactly!? Oh! You want me to go the complete WRONG way to get to my destination, okay

!" I am honestly very annoyed that the AI is so incompetent at almost everything! People say the AI is better in T:ANE, I don't believe this statement at all. If someone could
prove that the AI can do reliable switching in T:ANE, in a complex yard, like the Newcastle yard on ECML Kings Cross, by
only using the built-in commands, then I will be impressed. If it cannot do that, I hope the AI will be overhauled in TRS2018 (also known as Trainz: Next).
The AI are truly not intelligent and are only as "smart" as the logic you apply to them. Do they get confused sometimes? Yes, but that's due to other factors and not actually the AI carrying out their commands.
It's sad to say this and be so unkind to say that Harry, Ami, Alan, and the rest of the AI drivers we've grown to love (and hate) are nothing more than bots created to move our virtual trains. Without telling them what to do, via the commands we place in their schedules, they will sit there awaiting instructions. Like any other programmed device or script, the commands need to be logical. When you are giving the AI commands, they are being programmed. They can't read our minds and sometimes what we are thinking our intention is for them doesn't match what we tell them to do.
When programming devices, or in the case of AI drivers, we need to keep things as simple as possible. Yes, that famous KISS saying applies here 100% of the time. This also means that your track must be simple as well. You can have a gazillion tracks laid out in the prototypical fashion, however, you need to ensure that the AI can still navigate the track. To make a complex layout simple, you use waypoints or in our case track marks.
Knowing where to place track marks comes with experience. You'll find that sometimes even having too many track marks will make matters worse. So where to place track marks?
Placing them at the ends of sidings near the bumper. Use that to guide a driver to the end of a siding. If this is a balloon type setup, such as a passing siding or runaround track, placing track marks at either end usually works.
If there's a bypass track, let's say to go around a yard, there needs to be track marks at the beginning, middle, and end.
To have the AI negotiate a busy stretch of track, with lots of switches, place a track marks at various points along the path of travel. This can guide the AI through the interlocking and across the junctions rather easily.
Direction Marks. Direction marks work in conjunction with track marks, not in the numbers that the track marks are used.
Direction marks work to guide the AI on to specific tracks and in one direction. They are great for setting up passing sidings on a single-track line with meeting points. They also work as do not enter signs and can be used to prevent AI drivers from entering into sidings. If you plan to do switching, and let the AI drive the mainline, this works very well since it keeps the AI from wandering off to nowhere to get around an obstacle.
For loop settings, such as what the OP uses, a combination of track marks plus direction marks work. The direction mark forces the AI to go a specific way down the line while the track mark keeps the AI going forward by periodically placing the track marks along the route. This is used heavily on my large Ozark Valley and Western to control the hidden loops. The AI enters the loop as directed by the direction marks, then hit the track marks spaced on the points of the compass. T-1, T-2, T-3, etc., with enough to prevent the driver from backing up.
The reason for this setup is the AI will seek the shortest between two points even if that distance is longer via track miles, the distance is actually closer as straight as the crow flies. To prevent the AI from going backwards to reach that mark, the direction mark prevents the AI from exiting the loop and the closer placed on-loop track marks keep the AI directed farther away from the marks at the origin of the loop.
So there's still a whole lot more to this and this only scratches the surface such as signaling, Navigate To/Via versus Drive To/Via industry or track mark and so on.