Intermittent 500 Error on the New Agents SDK + Retrieving Metadata with FileSearchTool

Hey everyone! I’m currently using the new OpenAI Agents SDK and would like to share an issue I’m experiencing, as well as ask for help on retrieving metadata from vector searches.


1. Intermittent 500 Error

I’m occasionally getting a 500 error when my agent tries to answer some questions. Here’s the log:

Error getting response: Error code: 500 - {
  'error': {
    'message': 'An error occurred while processing your request. You can retry your request, or contact us through our help center at help.openai.com if the error persists. Please include the request ID req_10fe5c8c4a3fa296755a0607e6a9d823 in your message.',
    'type': 'server_error',
    'param': None,
    'code': 'server_error'
  }
}. (request_id: req_10fe5c8c4a3fa296755a0607e6a9d823)

Trace:

  • The bug doesn’t always happen. It occurs with some specific questions, and then if I retry later, it might work.
  • At first, I thought it could be caused by corrupted files in my vector store (I had some characters that broke indexing). I removed those and reuploaded everything.
  • Now, the vector store has 329 files with purpose="user_data", all properly indexed, yet the 500 error still appears randomly.

Questions about the 500 Error

  1. Has anyone else experienced this intermittent 500 error on the new Agents SDK?
  2. Is there any additional config or workaround that might help prevent it?
  3. Since it happens randomly, could it be something internal to the API or something in my call flow?

2. Retrieving Metadata with FileSearchTool

I’m using the FileSearchTool from the Agents SDK. My goal is to store the link attribute in each file’s metadata so the agent can return the original reference at the end of its answer.

Simplified upload code:

vector_store_file = client.vector_stores.files.create(
    vector_store_id=base_id,
    file_id=file_id,
    attributes={
        "link": link,
    },
)

Agent configuration:

Agent(
    name='Agente de Fundamentos',
    instructions=FUNDAMENTOS_AGENT,
    model="gpt-4o-mini",
    tools=[
        FileSearchTool(
            max_num_results=5,
            vector_store_ids=[vector_store_id],
            include_search_results=True,
        ),
    ],
)

Even with include_search_results=True, the agent still doesn’t return the link attribute from the matching files in the vector store. I’d like to display this source link at the end of the agent’s response.

Questions about Metadata

  1. What’s the proper way to access file attributes retrieved by FileSearchTool?
  2. Is there a way to instruct the agent to automatically include those metadata fields in the final answer?
  3. Does anyone have a snippet showing how to retrieve and format metadata within the agent’s execution flow?
  4. I know I could call the vector store search API directly, for example:
    results = client.vector_stores.search(
        vector_store_id=vector_store.id,
        query=user_query,
    )
    
    But before I implement a custom search tool, is there a simpler way to do this with the built-in FileSearchTool?

Request ID for reference: req_10fe5c8c4a3fa296755a0607e6a9d823.

Any help on fixing the 500 error or retrieving metadata with the new Agents SDK would be greatly appreciated! Let me know if you need more details or code snippets. Thank you!

I am having the exact same issue. Any news?

I managed to ‘fix’ the problem by switching from the GPT-4o mini model to GPT-4o. I’m not sure if the issue is really with the mini model or if it’s something related to its integration with the new SDK tools, but for me, that change solved the 500 error.

1 Like