Or maybe like this?
The question asks how many items he will manage to carry out **from the treasury**, not from the castle.
He will carry out eight bags and be caught in the courtyard.
But I can't agree with that. The definition of the word "carry out" is given above the question. If the wording were different, for example, "safely carry out = 5 minutes, and how much can be carried out?", then one could argue. But as it is, "carry out" means "carry out".
Even if "carry out" means different things to us, it is unknown how much time is required to leave the treasury, more than a minute or less. If it's more, then the treasure won't be carried out anywhere and will remain in the same room.