{"record":{"id":"bcbd18eb6845daba","repo":"HKUDS/DeepTutor","slug":"response-failed-response-error-detail-event-5","errorCode":null,"errorMessage":"Response failed: {_response_error_detail(event)[:500]}","messagePattern":"Response failed: (.+?)","errorType":"error_code","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"deeptutor/services/llm/provider_core/openai_responses/parsing.py","lineNumber":247,"sourceCode":"                    continue\n                # Look up by the ids this item actually carries; the\n                # placeholder is only a fallback for the id we report back.\n                raw_item_id = item.get(\"id\")\n                buf = tool_call_buffers.get(call_id=call_id, item_id=raw_item_id)\n                tool_calls.append(\n                    _build_tool_call(\n                        call_id=call_id,\n                        item_id=(buf.item_id if buf else raw_item_id)\n                        or _ToolCallBuffers.PLACEHOLDER_ITEM_ID,\n                        name=(buf.name if buf else \"\") or item.get(\"name\") or \"\",\n                        arguments=(buf.arguments if buf else \"\") or item.get(\"arguments\") or \"{}\",\n                    )\n                )\n        elif event_type == \"response.completed\":\n            status = (event.get(\"response\") or {}).get(\"status\")\n            finish_reason = map_finish_reason(status)\n        elif event_type in {\"error\", \"response.failed\"}:\n            raise RuntimeError(f\"Response failed: {_response_error_detail(event)[:500]}\")\n\n    return content, tool_calls, finish_reason\n\n\ndef parse_response_output(response: Any) -> LLMResponse:\n    \"\"\"Parse an SDK Response object into LLMResponse.\"\"\"\n    if not isinstance(response, dict):\n        dump = getattr(response, \"model_dump\", None)\n        response = dump() if callable(dump) else vars(response)\n\n    output = response.get(\"output\") or []\n    content_parts: list[str] = []\n    tool_calls: list[ToolCallRequest] = []\n    reasoning_content: str | None = None\n\n    for item in output:\n        if not isinstance(item, dict):\n            dump = getattr(item, \"model_dump\", None)","sourceCodeStart":229,"sourceCodeEnd":265,"githubUrl":"https://github.com/HKUDS/DeepTutor/blob/3e82f130422a813cdd73c10b21a44e9325f5821a/deeptutor/services/llm/provider_core/openai_responses/parsing.py#L229-L265","documentation":"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.","triggerScenarios":"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.","commonSituations":"Content moderation triggers; overloaded upstream models; malformed tool definitions that fail only once generation starts.","solutions":["Read the truncated detail in the message — it names the upstream failure reason.","Fix the request (prompt/tool schema) if the detail cites validation or policy.","Retry on transient upstream failures; check status pages for incidents."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    content, calls, finish = await consume_sse(response, on_delta)\nexcept RuntimeError as e:\n    if str(e).startswith('Response failed:'):\n        handle_upstream_failure(e)  # log detail, decide retry vs user error\n    raise","preventionTips":["Treat response.failed/error events as terminal; don't resume the stream","Log the truncated detail for policy/validation diagnosis","Retry only when the detail suggests transient upstream conditions"],"tags":["sse","openai-responses","streaming","upstream-failure"],"backgroundTag":"llm-stream-failed-event","analyzedSha":"3e82f130422a813cdd73c10b21a44e9325f5821a","analyzedAt":"2026-08-27T06:57:25.364Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}