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"
Maintainer antworten meist innerhalb von 1 Tag
@SparshGarg999 arbeitet bereits daran.
Seit 15.8.2026.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 55/100
Rechercherichtung
Beginne damit, den Streaming-Ablauf der Responses API mit client.responses.create(..., stream=True), stream.close() und conversations.items.list() zu reproduzieren. Verfolge anhand des verlinkten JavaScript SDK-Fixes, wie response.output_item.added-Ereignisse beim Schließen des Streams verarbeitet werden. Als erledigt gilt die Aufgabe, wenn das function_call-Element nach dem Abbruch persistiert wird und der nachfolgende function_call_output-Turn ohne einen 400-Fehler erfolgreich ist.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- Python
- Sterne
- 32k
- Forks
- 6.7k
- Ø Merge
- 15 Std. 56 Min.
- Gemergte PRs (30 T.)
- 179
Entwicklungsumgebung
Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus openai/openai-python
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
openai/openai-python#4156 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
openai/openai-python#4022 · 23 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
fix(auth): SubjectTokenProviderError drops response and duplicates error message in workload identity providersEvtl. vergeben @mohmedmm hat das vor 34 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 86/100
openai/openai-python#4017 · 5 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Define + export `ServiceTiers` string literalEvtl. vergeben @SparshGarg999 hat das vor 83 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
openai/openai-python#3556 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Empty OPENAI_BASE_URL prevents fallback to default API endpointEvtl. vergeben @Sehastrajit-S hat das vor 49 Tagen übernommen. Offenbug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
openai/openai-python#2927 · 7 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in openai/openai-python
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 69/100
jejjohnson/gaussx#752 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
521xueweihan/HelloGitHub#4270 ·
-
enhancement owner: den-haag
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
Maintainer antworten meist innerhalb von 6 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
ok-oldking/ok-wuthering-waves#1828 ·
Maintainer antworten meist innerhalb von 1 Tag
-
lesson-submission pending-review
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 65/100
Ikalus1988/MisakaNet#4512 ·
Maintainer antworten meist innerhalb von 1 Tag