Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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"

Abierto
#3,561 14 comentarios 2 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@SparshGarg999 ya está trabajando en esto.

Desde el 15/8/2026.

  • #2 de @SparshGarg999 — abierto
  • #3621 de @SparshGarg999 — cerrado sin fusionar
  • #3942 de @00200200 — cerrado sin fusionar

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
python
Área
api

Línea de trabajo

Empieza reproduciendo el flujo de la API de Responses en streaming con client.responses.create(..., stream=True), stream.close() y conversations.items.list(). Rastrea cómo se gestionan los eventos response.output_item.added cuando el stream se cierra, tomando como contexto la corrección vinculada del JavaScript SDK. Se considera terminado cuando el elemento function_call persiste después de abortar y el turno posterior function_call_output tiene éxito sin un error 400.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

bug
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
  1. client.conversations.create() → keep conv_id.
  2. Stream a responses.create(..., conversation=conv_id, tools=[...], stream=True) whose prompt triggers the tool.
  3. On the response.output_item.added event for the function_call item, close the stream (stream.close()).
  4. Verify the conversation's items: conversations.items.list(conversation_id=conv_id) → empty, the function_call was never committed.
  5. Send the next turn on the same conversation with the tool's function_call_output + a user message.
  6. 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

Lenguaje dominante
Python
Estrellas
31.8k
Forks
7.3k
Merge medio
1 d 3 h
PR fusionados (30 d)
131

Preparar el entorno

Abrir en Codespaces

Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de openai/openai-python

Todos los issues de openai/openai-python

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.