OpenAIResponsesHttpLLMService: no short stream-idle deadline after stream creation; SDK read timeout defaults to 600 seconds
pipecat 1.12.0, OpenAIResponsesHttpLLMService. Reproduced with openai 2.54.0 (locally) and seen in production with openai 3.19.2.
When enabled, retry_on_timeout bounds the first responses.create() await (_create_stream, responses/llm.py ~1300-1320). Its retry has no additional Pipecat deadline, but remains subject to the SDK timeout. After stream creation, the SDK read timeout bounds waits for network data, not complete SSE events. _create_client passes no timeout, so that is the SDK default of 600 seconds, and a byte-silent stream can leave the turn without an error for the whole of a normal phone call: no ErrorFrame, no on_completion_timeout. Ordinary LLM frames queue behind that request; interruption and cancellation frames can still interrupt it.
For comparison, the WebSocket variant arms an output deadline in _receive_response_events (output_timeout_secs), which is cleared by any event other than response.created (including response.in_progress), so it does not guarantee first text or a tool call either. GoogleLLMService has stream_idle_timeout_secs (#5249), whose note says OpenAI gets this "free from the SDK"; with the default 600 s it effectively does not. Related: #5804 (the same gap on the WebSocket variant after the first event).
Stock repro (no app code; a local server sends response.created then nothing; openai 2.54.0):
# repro_stock.py (below): retry_on_timeout=True, retry_timeout_secs=1.0
RESULT extra timeout: False | errors within 20 s: NONE (turn still open)
RESULT extra timeout: True | errors within 20 s: [(2.3, 'LLM completion timeout')] # Settings(extra={"timeout": 2.0})Settings.extra={"timeout": N} works today because _build_response_params merges extra into responses.create(**params), but it is not documented as a timeout lever. The SDK's automatic retries (default 2; each retry of a request whose headers never arrive waits the full timeout again) are not exposed through a dedicated public constructor parameter on the Responses services; we set them with the SDK's with_options(max_retries=...) on the service's client.
Note for a fix: with openai 3.19.2 a read timeout on the open stream surfaces as openai.APITimeoutError (openai 3.19.2 _streaming.py lines 58 and 173 wrap it), not as an httpx timeout, so the TIMEOUT_EXCEPTIONS branch and on_completion_timeout do not fire for it; it is reported as Error during inference: Request timed out.
Ask: a documented stream_idle_timeout_secs on both Responses services matching the Google one (an event-idle deadline bounding every gap, first event included, separate from the SDK's network-read timeout), and either a max_retries constructor argument or a documented way to pass client options. Happy to open a PR modelled on #5249.
Production impact (no client data): two phone calls in 1,360 turns over 6 days; one caller sat 2 min 49 s in silence and hung up, one waited 18.7 s until she spoke again.
repro_stock.py"""Stock pipecat repro: OpenAIResponsesHttpLLMService waits indefinitely on a stream that opens and goes quiet.
No engine code. A local server answers /v1/responses with 200 + response.created, then sends nothing.
python repro_stock.py # retry_on_timeout=True, retry_timeout_secs=1: still no ErrorFrame after 20 s
python repro_stock.py --extra # Settings(extra={"timeout": 2}): ErrorFrame ~2 s after the stall
"""
import asyncio, json, sys, time
from aiohttp import web
from pipecat.frames.frames import LLMContextFrame
from pipecat.processors.aggregators.llm_context import LLMContext
from pipecat.services.openai.responses.llm import OpenAIResponsesHttpLLMService
from pipecat.tests.utils import run_test
async def stall(request):
await request.read()
resp = web.StreamResponse(status=200, headers={"Content-Type": "text/event-stream"})
await resp.prepare(request)
ev = {"type": "response.created", "sequence_number": 0, "response": {"id": "r", "object": "response",
"created_at": 0, "model": "m", "output": [], "status": "in_progress", "parallel_tool_calls": False,
"tool_choice": "auto", "tools": []}}
await resp.write(f"event: response.created\ndata: {json.dumps(ev)}\n\n".encode())
await asyncio.sleep(3600)
async def main(use_extra):
app = web.Application(); app.router.add_post("/v1/responses", stall)
runner = web.AppRunner(app); await runner.setup(); await web.TCPSite(runner, "127.0.0.1", 8898).start()
settings = OpenAIResponsesHttpLLMService.Settings(model="gpt-4.1", extra={"timeout": 2.0} if use_extra else {})
llm = OpenAIResponsesHttpLLMService(api_key="x", base_url="http://127.0.0.1:8898/v1", settings=settings,
retry_on_timeout=True, retry_timeout_secs=1.0)
errors, t0 = [], time.monotonic()
@llm.event_handler("on_error")
async def on_error(_p, f):
errors.append((round(time.monotonic() - t0, 1), f.error))
ctx = LLMContext(messages=[{"role": "user", "content": "hi"}])
task = asyncio.create_task(run_test(llm, frames_to_send=[LLMContextFrame(ctx)]))
await asyncio.wait({task}, timeout=20)
print("RESULT extra timeout:", use_extra, "| errors within 20 s:", errors or "NONE (turn still open)", flush=True)
import os; os._exit(0)
asyncio.run(main("--extra" in sys.argv))
Source: pipecat-ai/pipecat