When you write an agent that works on New or Modified Documents, the UnprocessedDocuments collection will sometimes return a deletion stub instead of only returning documents (this is probably a bug, but it's been around since R4). If you do not program for this case, your agent may suddenly stop working because it tried to access an item on a document that has been deleted.
You can check if a document is a deletion stub with this:
If (doc.Size = 0) then
'doc is a deletion stub
Else
'doc is not a deletion stub
End If
You can also use a comparision of:
If (doc.NoteID = "")