HKUDS/DeepTutor · error · RuntimeError

Response failed: {_response_error_detail(event)[:500]}

Error message

Response failed: {_response_error_detail(event)[:500]}

What it means

While consuming the SSE stream from an OpenAI Responses API call, an event of type 'error' or 'response.failed' arrived; consume_sse raises RuntimeError with the first 500 chars of the failure detail extracted from the event.

Source

Thrown at deeptutor/services/llm/provider_core/openai_responses/parsing.py:247

                    continue
                # Look up by the ids this item actually carries; the
                # placeholder is only a fallback for the id we report back.
                raw_item_id = item.get("id")
                buf = tool_call_buffers.get(call_id=call_id, item_id=raw_item_id)
                tool_calls.append(
                    _build_tool_call(
                        call_id=call_id,
                        item_id=(buf.item_id if buf else raw_item_id)
                        or _ToolCallBuffers.PLACEHOLDER_ITEM_ID,
                        name=(buf.name if buf else "") or item.get("name") or "",
                        arguments=(buf.arguments if buf else "") or item.get("arguments") or "{}",
                    )
                )
        elif event_type == "response.completed":
            status = (event.get("response") or {}).get("status")
            finish_reason = map_finish_reason(status)
        elif event_type in {"error", "response.failed"}:
            raise RuntimeError(f"Response failed: {_response_error_detail(event)[:500]}")

    return content, tool_calls, finish_reason


def parse_response_output(response: Any) -> LLMResponse:
    """Parse an SDK Response object into LLMResponse."""
    if not isinstance(response, dict):
        dump = getattr(response, "model_dump", None)
        response = dump() if callable(dump) else vars(response)

    output = response.get("output") or []
    content_parts: list[str] = []
    tool_calls: list[ToolCallRequest] = []
    reasoning_content: str | None = None

    for item in output:
        if not isinstance(item, dict):
            dump = getattr(item, "model_dump", None)

View on GitHub (pinned to 3e82f13042)

Solutions

  1. Read the truncated detail in the message — it names the upstream failure reason.
  2. Fix the request (prompt/tool schema) if the detail cites validation or policy.
  3. Retry on transient upstream failures; check status pages for incidents.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    content, calls, finish = await consume_sse(response, on_delta)
except RuntimeError as e:
    if str(e).startswith('Response failed:'):
        handle_upstream_failure(e)  # log detail, decide retry vs user error
    raise

Prevention

When it happens

Trigger: Calling _request_codex (or the SSE parsing tests) where the stream emits response.failed/error — e.g. server-side content policy rejection, internal error, or invalid request detected mid-stream.

Common situations: Content moderation triggers; overloaded upstream models; malformed tool definitions that fail only once generation starts.

Related errors


AI-assisted analysis of HKUDS/DeepTutor@3e82f13042 (2026-08-27). Data as JSON: /api/errors/bcbd18eb6845daba. Report an issue: GitHub.