Error running command msearch: BrowserToolBase.run_msearch() got multiple values for argument 'session'

Hello OpenAI Community,

I’ve encountered an issue while working with the file search tool in the OpenAI API, specifically related to vector store integration. The error message I’m seeing is:

“Error running command msearch: BrowserToolBase.run_msearch() got multiple values for argument ‘session’”

Context:

  • Use Case: I’m building an assistant that relies heavily on the file search tool for accessing various knowledge files stored in a vector store. The assistant’s role is to answer user queries by retrieving relevant information from these files.
  • Environment: The assistant is deployed using the OpenAI API. I received this error when querying the assistant about its own operations.
  • Code Details: My code does not explicitly call msearch. Instead, the error appears to originate from the assistant’s internal operations, specifically when it tries to process certain commands.

Steps I’ve Taken:

  1. Updated SDK: Ensured that the OpenAI Python SDK is up-to-date (currently using version 1.40.x).
  2. Refined Instructions: Reviewed and refined the assistant’s instructions to ensure that they are clear and concise, and that they match the structure of the files in the vector store.
  3. File Optimization: Consolidated multiple files in the vector store into fewer, more organized files to streamline the assistant’s search process.
  4. Removed Complex Instructions: Removed complex instructions related to UTM handling, which could have been complicating the assistant’s operations.

Additional Information:

  • The error was first reported by the assistant itself when I queried it about operational issues. This suggests that the issue might be internal to how the assistant handles the file search commands.
  • I’ve considered that this error could be related to the internal workings of the file search tool, particularly when handling multiple files or complex searches, but I’m unsure of the exact cause or solution.

Question:

  • What could be causing this error, and how might I resolve it?
  • Are there specific debugging steps I should take to pinpoint the source of the issue?

Any guidance or suggestions would be greatly appreciated.

Thank you!

Hello!
I’m having basically the same issue as you.
Did you find any way to fix this?

Hi,

Can you post a code snippet of the API calling code, thanks.

1 Like

Do you mean my AI outputs?
The requests are done the same as other functions callings, and that works just fine.
Sometimes the output contains this “msearch”, and i havent specified to use this anywhere.

Hello, Zornigs!

Yes, I resolved this issue. I was incorrectly handling the file_citation. Regarding the error, more experienced colleagues eventually pointed out that asking the assistant itself about the errors it encounters while performing actions is not the correct approach. The assistant cannot give a direct answer and starts hallucinating. So, they told me that I had been looking for a non-existent error for two days! Interestingly, you also faced such an issue, so it was probably not just a hallucination. In any case, pay attention to the response handling. In my code, I implemented it like this:

if run_status.status == 'completed':
                messages = client.beta.threads.messages.list(thread_id=thread_id)
                if messages and messages.data and messages.data[0].content:
                    message_content = messages.data[0].content[0].text
                    annotations = getattr(message_content, 'annotations', None)
                    citations = [  ]
                    if annotations:
                        for index, annotation in enumerate(annotations):
                            message_content.value = message_content.value.replace(annotation.text, f"[{index}]")
                            if file_citation := getattr(annotation, "file_citation", None):
                                cited_file = client.files.retrieve(file_citation.file_id)
                                citations.append(f"[{index}] {cited_file.filename}")
                    logging.info("Run completed, returning response")
                    return jsonify({"answer": message_content.value, "status": "completed"})