We have an agent that has the filesearch tool enabled on a vector store. But we can’t configure it with for example max_results, we know this does work in the filesearch node but it actually complicates our integration, since it is easier to give the tool to the agent. With the tool enabled we always get 20 files even if the files are not even relevant for the question that was made. Can this be added ?
OpenAI’s file search does have two parameters to configure the file_search tool response size the AI model receives back.
First, like you desire, one that promises to control the number of chunks returned (not files) - and there’s a possibility it could be working now if you want to try it:
The other parameter, that would serve better to reject irrelevant results - a semantic comparison threshold:
{
"model": "gpt-4.1",
"tools": [{
"type": "file_search",
"vector_store_ids": ["vs_1234567890"],
"ranking_options": {"score_threshold": 0.40},
}],...
Increasing the number ranged 0.0-1.0 increases the similarity score required for ranked chunks to appear.
OpenAI has no direct documentation of using score_threshold as plainly as my sample above: you have to expand the API reference several times to see API parameter inputs under “tools” to see it exists for the Responses API endpoint.
Hi and welcome to the Community!
Just to confirm: is this a feature request because max_num_results isn’t available in the Agent Builder? If so, could you export the code and apply the change there as a workaround?
For reference, I verified that File Search works as expected with max_num_results in both the Responses API and the Assistants API.