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"
I maintainer di solito rispondono entro 1 giorno
@SparshGarg999 ci sta già lavorando.
Dal 15/8/2026.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Inizia riproducendo il flusso della Responses API in streaming con client.responses.create(..., stream=True), stream.close() e conversations.items.list(). Traccia come vengono gestiti gli eventi response.output_item.added quando lo stream si chiude, usando come contesto il fix collegato del JavaScript SDK. Il lavoro è completato quando l’elemento function_call viene persistito dopo l’interruzione e il turno function_call_output successivo riesce senza un errore 400.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
- Lingua principale
- Python
- Stelle
- 31.8k
- Fork
- 7.3k
- Merge medio
- 1g 1h
- PR unite (30g)
- 137
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di openai/openai-python
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
openai/openai-python#4022 · 19 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
fix(auth): SubjectTokenProviderError drops response and duplicates error message in workload identity providersForse già presa @mohmedmm l’ha presa 11 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
openai/openai-python#4017 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Querystring drops explicit empty-string scalar valuesForse già presa @sylvesterkaczmarek l’ha presa 33 giorni fa. Apertasdk-breaking-change v4
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
openai/openai-python#3837 ·
I maintainer di solito rispondono entro 1 giorno
-
Define + export `ServiceTiers` string literalForse già presa @SparshGarg999 l’ha presa 60 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
openai/openai-python#3556 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Empty OPENAI_BASE_URL prevents fallback to default API endpointForse già presa @Sehastrajit-S l’ha presa 26 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
openai/openai-python#2927 · 6 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di openai/openai-python
Issue simili
-
fix(accounts): Balance Sheet and Profit and Loss crash on PostgreSQL due to MySQL force_indexAperta
Difficoltà 1/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Discord webhook notifications fail with HTTP 403 (Cloudflare blocks default urllib User-Agent)Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
tharje/spooler-v2#20 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Bump version of azure-servicebusForse già presa @joostlek l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
home-assistant/core#186275 ·
I maintainer di solito rispondono entro 1 giorno
-
documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100