Bug
_sanitize_openai_conversation_item() in agents/run_internal/session_persistence.py:568 unconditionally strips id from all conversation items before calling session.add_items():
def _sanitize_openai_conversation_item(item):
if isinstance(item, dict):
clean_item = cast(dict[str, Any], strip_internal_input_item_metadata(item))
clean_item.pop("id", None) # strips id from ALL items
clean_item.pop("provider_data", None)
return cast(TResponseInputItem, clean_item)
return item
The OpenAI Conversations API requires id on built-in tool-call item types. The SDK's own response param type definitions confirm this:
ResponseFileSearchToolCallParam — id: Required[str] (openai/types/responses/response_file_search_tool_call_param.py:43)
ResponseCodeInterpreterToolCallParam — id: Required[str] (openai/types/responses/response_code_interpreter_tool_call_param.py:37)
ResponseFunctionWebSearchParam — id: Required[str] (openai/types/responses/response_function_web_search_param.py:79)
When the sanitizer strips id from these items, the Conversations API returns 400 Missing required parameter: 'items[0].id'.
Reproduction
- Create an agent with
FileSearchTool and a real vector store
- Use
OpenAIConversationsSession for conversation persistence
- On turn 1, trigger the agent to use file_search (produces
file_search_call items)
- On turn 2, send any follow-up message
- The SDK collects turn 1's output items, sanitizes them (stripping
id), and calls add_items()
- The Conversations API rejects the batch because
file_search_call is missing id
Failing batch shape
[
{"type": "file_search_call", ...}, // id: Required — stripped by sanitizer → 400 error
{"type": "function_call", ...}, // id: Optional — works without id
{"type": "function_call_output", ...} // id: Optional — works without id
]
Note: function_call has id as optional in the SDK type definitions (response_function_tool_call_param.py:29). The confirmed required-id types are file_search_call, code_interpreter_call, and web_search_call.
Workaround
Override the sanitizer to only strip id from item types where it's optional (role == "user", type == "function_call_output"), preserving it for everything else.
Environment
openai-agents==0.13.5
openai==2.30.0
- Python 3.13.6
- Agent uses:
FileSearchTool, CodeInterpreterTool, custom @function_tool tools
- Session:
OpenAIConversationsSession (subclassed for batching)
Bug
_sanitize_openai_conversation_item()inagents/run_internal/session_persistence.py:568unconditionally stripsidfrom all conversation items before callingsession.add_items():The OpenAI Conversations API requires
idon built-in tool-call item types. The SDK's own response param type definitions confirm this:ResponseFileSearchToolCallParam—id: Required[str](openai/types/responses/response_file_search_tool_call_param.py:43)ResponseCodeInterpreterToolCallParam—id: Required[str](openai/types/responses/response_code_interpreter_tool_call_param.py:37)ResponseFunctionWebSearchParam—id: Required[str](openai/types/responses/response_function_web_search_param.py:79)When the sanitizer strips
idfrom these items, the Conversations API returns400 Missing required parameter: 'items[0].id'.Reproduction
FileSearchTooland a real vector storeOpenAIConversationsSessionfor conversation persistencefile_search_callitems)id), and callsadd_items()file_search_callis missingidFailing batch shape
[ {"type": "file_search_call", ...}, // id: Required — stripped by sanitizer → 400 error {"type": "function_call", ...}, // id: Optional — works without id {"type": "function_call_output", ...} // id: Optional — works without id ]Note:
function_callhasidas optional in the SDK type definitions (response_function_tool_call_param.py:29). The confirmed required-id types arefile_search_call,code_interpreter_call, andweb_search_call.Workaround
Override the sanitizer to only strip
idfrom item types where it's optional (role == "user",type == "function_call_output"), preserving it for everything else.Environment
openai-agents==0.13.5openai==2.30.0FileSearchTool,CodeInterpreterTool, custom@function_tooltoolsOpenAIConversationsSession(subclassed for batching)