Aborting a streaming Responses API request drops the function_call item, breaking the next turn with 400 "No tool call found for function call output"
Les mainteneurs répondent en général sous 1 jour
@SparshGarg999 y travaille déjà.
Depuis le 15/8/2026.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 55/100
Piste de recherche
Commencez par reproduire le flux de l’API Responses en streaming avec client.responses.create(..., stream=True), stream.close() et conversations.items.list(). Suivez la manière dont les événements response.output_item.added sont traités lorsque le flux se ferme, en vous appuyant sur le correctif lié du JavaScript SDK. Le travail est terminé lorsque l’élément function_call est persisté après l’abandon et que le tour function_call_output suivant réussit sans erreur 400.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
When a Responses API request is aborted mid-stream (client closes the stream) after a function_call item has already been streamed back, that item is never persisted to the conversation. The next turn on the same conversation that sends the matching function_call_output fails with:
400 No tool call found for function call output with call_id call_q7hr5y6HlCZkOvJ4t5cYPZM9.
The caller executes the tool locally after the abort, so the output exists and is valid — but the remote conversation has no record of the tool call it belongs to. The API gives no signal at abort time that the streamed items were discarded.
Additional context
Same issue has been fixed in the js sdk in https://github.com/openai/openai-agents-js/pull/1241
To Reproduce
client.conversations.create()→ keepconv_id.- Stream a
responses.create(..., conversation=conv_id, tools=[...], stream=True)whose prompt triggers the tool. - On the
response.output_item.addedevent for thefunction_callitem, close the stream (stream.close()). - Verify the conversation's items:
conversations.items.list(conversation_id=conv_id)→ empty, thefunction_callwas never committed. - Send the next turn on the same conversation with the tool's
function_call_output+ a user message. - See
400 No tool call found for function call output with call_id ....
Code snippets
import openai
client = openai.OpenAI()
tools = [{
"type": "function",
"name": "get_weather",
"description": "Get the current weather for a location",
"parameters": {"type": "object", "properties": {"location": {"type": "string"}}, "required": ["location"]},
}]
conv = client.conversations.create()
conv_id = conv.id
# 1) streaming turn that triggers a tool call
stream = client.responses.create(
model="gpt-4.1-mini",
input="What is the weather in Amsterdam?",
conversation=conv_id,
tools=tools,
stream=True,
)
call_id = None
for event in stream:
if event.type == "response.output_item.added" and event.item.type == "function_call":
call_id = event.item.call_id
print("captured:", call_id)
stream.close() # abort mid-stream
break
# 2) the function_call was NOT persisted
items = client.conversations.items.list(conversation_id=conv_id)
print("persisted items:", [i.type for i in items.data]) # -> []
# 3) next turn on the SAME conversation
client.responses.create(
model="gpt-4.1-mini",
input=[
{"type": "function_call_output", "call_id": call_id, "output": '{"temp": 18, "condition": "cloudy"}'},
{"type": "message", "role": "user", "content": "Is it cold?"},
],
conversation=conv_id,
tools=tools,
)
# -> BadRequestError 400: No tool call found for function call output with call_id call_q7hr5y6HlCZkOvJ4t5cYPZM9.
OS
Windows 10
Python version
Python v3.11.5
Library version
openai v2.45.0
- Langage dominant
- Python
- Étoiles
- 32k
- Forks
- 7.3k
- Merge moyen
- 16 h 38 min
- PR mergées (30 j)
- 170
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de openai/openai-python
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
openai/openai-python#4156 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
openai/openai-python#4022 · 23 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
fix(auth): SubjectTokenProviderError drops response and duplicates error message in workload identity providersPeut-être pris @mohmedmm l’a pris il y a 31 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 86/100
openai/openai-python#4017 · 5 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Define + export `ServiceTiers` string literalPeut-être pris @SparshGarg999 l’a pris il y a 80 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
openai/openai-python#3556 · 3 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Empty OPENAI_BASE_URL prevents fallback to default API endpointPeut-être pris @Sehastrajit-S l’a pris il y a 46 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
openai/openai-python#2927 · 7 commentaires ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de openai/openai-python
Issues similaires
-
area:scripts area:tests bug priority:later
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Ikalus1988/MisakaNet#4358 ·
Les mainteneurs répondent en général sous 1 jour
-
Discovered ports from service discovery are never propagated to modules in Module.load()Peut-être pris @vishalmore90 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
OWASP/Nettacker#1828 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
aws-samples/sample-per-model-bedrock#708 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
-
[Performance] Bound resolve_api_hashes raw fallback reads to the 1 MiB region actually scannedOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
sjkim1127/Reversecore_MCP#365 ·
Les mainteneurs répondent en général sous 1 jour