Inconsistent results with file uploads via Assistant API

We’re using the Assistant API to create a special-purpose chat interface. We recently added the ability to attach files to the conversation, but we’re getting inconsistent and irregular results. Using the same assistant and uploaded file three times in a row, only one of the responses referenced the file content. One other response referred to a file that we don’t know anything about, and the other response just asked for more information.

From other questions here it seems like the file upload integration may still have some issues, but I wanted to see if anyone who’s encountered problems like this has a workaround. At first we thought there might be a race condition – like the system was processing the message before the files had been fully uploaded – but from checking my code it appears that the uploads all show state “processed” before we submit the user-entered message that refers to them.

Here’s the code we’re using:

        attachments = []
        for file in files:
            message_file = self.openai_client.files.create(
                file=(file.filename,, purpose="assistants"
                {"file_id":, "tools": [{"type": "file_search"}]}

        if not message:
            message = "Here are the files to review."


        except ...

Does this look okay?

Thanks in advance for any help or insight anyone can share!

It does look ok - but I wonder what kind of questions (and what kind of documents) you are processing, what kind of Assistnat prompt is supporting it. You could also consider to (also) enable code_interpreter on the (same) file. The file search is ‘RAG’ - so its ‘fuzzy’ at best at the momet. If the file is not too large - the code interpeter option will allow you to have the content ingested by code completion which can be more ‘exact’ than the file search.

I usually enable both in my incoming email processor.