LS object extraction intermittently fails on server

I’ve got an agent which extracts embedded files from documents to disk. I’ve included the relevant snippet of code below, where it checks the document for embedded docs and looks for RTFs where they’re embedded. Run locally, it extracts the expected files to the appropriate locations. Run on the server, however, it seems to fail to detect many of the files it was able to extract on the local run. For some but not all documents (and it’s always the same documents), this_doc.Hasembedded returns false despite the fact that a) the documents definitely have embedded files and b) when the agent is run locally on those same documents, it returns true. Instead, when run on the server, I get the “no embedded” message, with the correct document and title information. And, again, this only happens with a subset of documents. Maybe half of the documents processed on the server end up being processed correctly. What might be up with that?

(this_path is a root directory path, which I’ve determined gets correct values)

If this_doc.Hasembedded Then
Forall itm In this_doc.items
If (itm.Type = RICHTEXT) And Not(Left(itm.Name, 1) = “$”) Then
Print itm.Name
Forall o In itm.Embeddedobjects
If o.Type = EMBED_ATTACHMENT Then
thisfpath = this_path & o.Source
Call o.ExtractFile(thisfpath)
Print thisfpath & " extracted"
End If
End Forall
End If
End Forall
Else
Print “No embedded”, this_doc.metadata_documentid(0), this_doc.metadata_documentTitle(0)
End If