Issue Accessing Documents in Recent Vector Stores

Hi everyone,

I’m experiencing an issue when working with threads that use documents stored in Vector Stores. When I send a message within the thread and execute it, the response says it couldn’t access the associated document.
I’ve already double-checked that all identifiers are correctly linked:

  • FILE_ID
  • VECTOR_STORE_ID (which contains the FILE_ID)
  • THREAD_ID (which has the VECTOR_STORE_ID as a resource tool)

Strangely, this issue only occurs with new documents uploaded in the past few days. Everything works fine with documents uploaded before that.

Has anyone else run into this or know what might be causing it?

I tried again on a different test project and the same problem remains.

Code for the test:

from openai import OpenAI
from dotenv import load_dotenv

load_dotenv()


def custom_print(obj):
    """Print info about custom object"""

    print(str(obj), end="\n\n")


def main() -> None:
    # Initialize services
    openai = OpenAI()

    # Create an assistant
    assistant = openai.beta.assistants.create(
        name="TestAssistant",
        model="gpt-4o-mini",
        instructions="You are a virtual assistant expert in document analysis and information extraction. Your task will be to answer the user's queries by relying on your knowledge base. Your answers must be precise and detailed.",
        temperature=0.7,
    )
    custom_print(assistant)

    FILE_PATH = "./files/book.pdf"

    # Load file to OpenAI
    file = openai.files.create(file=open(FILE_PATH, "rb"), purpose="assistants")
    custom_print(file)

    # Create vector store
    vector_store = openai.beta.vector_stores.create(file_ids=[file.id])
    custom_print(vector_store)

    # Create a thread with that vector store as tool resource
    thread = openai.beta.threads.create(
        tool_resources={"file_search": {"vector_store_ids": [vector_store.id]}}
    )
    custom_print(thread)

    # Add message to the thread
    message = openai.beta.threads.messages.create(
        thread_id=thread.id,
        content="Write a resume about the document.",
        role="user",
    )
    custom_print(message)

    # Run and poll thread
    run = openai.beta.threads.runs.create_and_poll(
        assistant_id=assistant.id, thread_id=thread.id
    )
    custom_print(run)

    # Get response messages
    response = list(openai.beta.threads.messages.list(thread_id=thread.id, limit=1))[0]
    custom_print(response)


if __name__ == "__main__":
    main()

AI Response:

‘Please provide me with the specific document you would like me to summarize, or let me know if you would like me to analyze multiple documents.’