I’m integrating OpenAI tool calling in an async app and I’m intermittently hitting this error when submitting the tool output:
Error code: 400
Duplicate item found with id msg_XXXXXXXX.... Remove duplicate items from your input and try again.
(type: invalid_request_error, param: input, code: None)
This seems to occur specifically when the user sends an image file along with a prompt.
Logs show the same user message being handled twice for image+prompt inputs. I suspect this duplication results in repeated msg_... item IDs and triggers the Duplicate item found with id msg_... error during tool output submission.
I’m using tool calling (function tools) and I must submit tool output so the conversation can continue. The failure happens at the step where I submit the tool output / continue the run.
Important: I only submit a single function_call_output item to continue. With text-only messages, the exact same code path works for the rest.
Minimal payload I send to Responses API
[
{
"type": "function_call_output",
"call_id": "call_XXXXXXXXXXXX",
"output": "<json string>"
}
]
Minimal snippet
async def submit_output(client, conversation_id, call_id, output):
return await client.responses.create(
conversation=conversation_id,
model="gpt-5.2",
input=[{
"type": "function_call_output",
"call_id": call_id,
"output": output,
}],
stream=True,
)
Could this be an SDK issue?
Is there a recommended fix pattern in code?
Why would this happen only with image+prompt but not text-only , when I’m “using the same logic”?
Any known bugs where image uploads/attachments cause the user message event to fire twice or lead to duplicated input items?
- Python SDK:
openai==2.17 - API: Responses API
- Python 3.11.4
