Assistants v2 file_search not using the files in a consistent way

I used to have many assistants using knowledge retrieval in v1. Now, in v2, when I create assistants with files attached, they are not always called by the assistant.

There are some queries that need the file but the assistants just don’t use the file. It improved when I added to the system prompt that it should always check the file but I’m not sure if this is a reliable solution.

How can I force the assistant v2 to always use the attached files?

2 Likes

are the assistant’s custom instructions pointing it to search the files? Also when creating a run you can force the tools like file_search I believe .

1 Like

Yes, they are pointing to the files. The files are sometimes used but not always, that’s the problem. I expect the assistant to always use the files (as they did with v1). It seems that, since now the file_search is part of tools, and the tools are triggered only when the assistant thinks they are needed, the file_search tools are not always used.

I will try with tool_choice to force file_search as it happens with completions

1 Like

I am having a related issue where 8 out of 15 pdf’s contents were not seen at all, but deleting the vector store and recreating all 15 were seen immediately. This was not a timing issue but “read the pdf’s” code failed for some reason.

Thanks for sharing your issue. So, if I understand correctly, you didn’t experience that problem anymore after recreating the vector store? Did you originally create the vector store in v2 or was it a v1 assistant that was automatically migrated to v2?

For what it’s worth – I’ve had this issue consistently with the new v2, where uploaded files attached to thread won’t look at the file - I sent an email direct to one of the engineers - but haven’t heard back yet.

I am having the same issue. For around a month it was working fine. Now even if a create an assistant in openAI and not through the API, using V2, it wont do a file search at all on any of my assstants. This has been the issue for the last 24 hours or so.

1 Like

I have fixed this by entering the following line in the prompt:

Constraints

1: Never give an answer that has not been checked in the uploaded files.
2: xxxxx
3: xxxxx
6. You can only answer questions that can be found in the provided data sources. If you cannot find an answer, please ask for an e-mailaddress so an agent can follow up on the question.

Thanks. I haven’t tried again but I will and try with your constraints

I fixed most of the behaviour by changing the prompt and I also instruct the Assistants API to use the ToolsConstraint “file_search” as a required tool. If you do not give this hint, the Assistants API might respond without searching the vector DB.

Hereby my code for Assistant v2 API (C# OpenAI SDK):

var runOptions = new RunCreationOptions() { AdditionalMessages = { content } };
runOptions.ToolConstraint = new ToolConstraint(new FileSearchToolDefinition() { MaxResults = 20 });

Works quite good now! and by using the GPT4o-mini model, it is quite cheap as well.

2 Likes