Seriously, there's no need to call a normal feature a bug. The situation is completely standard. To fix it, you'll have to rewind and replay, or better yet, anticipate the possibility of this happening and prevent it.
Why doesn't a weak caravan attack a Castle...? And why should it? It definitely won't capture the Castle. The only sensible move for such a unit is to reach a field tavern, if there is one. But even if there isn't a tavern, it still isn't obligated to just wander around aimlessly. I think the developers had this in mind.
Added 5 minutes later
I specifically moved away from the Castle - I don't want to enter, as they say... the unit just walks by. That's why it's unclear - is all this necessary?... I'll try to replay it before evening, who knows - maybe I'll get lucky.
Added 7 minutes later
well, I said - it was just stalling for time to build suspense =);););)) :D :D :D:D :D :D:D :D :D:D :D :D