Check if there's a document before trying to get assistants from it.
(cherry picked from commit 1c3f926554c20a73bbf115f2dcd6221f8a090fc7)