{"record":{"id":"94994035b1f98421","repo":"iflytek/astron-agent","slug":"str-e-large-model-request-failure","errorCode":null,"errorMessage":"{str(e)} (large model request failure)","messagePattern":"(.+?) \\(large model request failure\\)","errorType":"exception","errorClass":"ThirdPartyException","httpStatus":null,"severity":"error","filePath":"core/knowledge/llm/openai_llm.py","lineNumber":107,"sourceCode":"                        True if chunk.choices[0].finish_reason == \"stop\" else False\n                    )\n                    span_context.add_info_events(\n                        {\"LLM_OUTPUT\": json.dumps(chunk.dict(), ensure_ascii=False)}\n                    )\n\n                    if finished:\n                        if len(res.content) > 0:\n                            yield res, False\n                            res.content = \"\"\n                            yield res, True\n                        else:\n                            res.content = \"\"\n                            yield res, True\n                    else:\n                        yield res, False\n        except Exception as e:\n            logger.error(f\"The request for a large model failed：{e}\")\n            raise ThirdPartyException(str(e))\n","sourceCodeStart":89,"sourceCodeEnd":108,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/knowledge/llm/openai_llm.py#L89-L108","documentation":"stream_chat in openai_llm.py catches any exception during the LLM streaming request and re-raises it as a bare ThirdPartyException(str(e)) with the message '(large model request failure)' implied by the log. It hides the original exception type, so the message text is whatever the underlying OpenAI client/network error produced.","triggerScenarios":"Streaming chat completion fails: invalid/expired API key, model name not available to the account, rate limit (429), context length exceeded, network drop mid-stream, or malformed response chunk (e.g. res lacking expected attributes).","commonSituations":"Wrong OPENAI_API_KEY or base_url in model config; requesting a model the key has no access to; exceeding tokens-per-minute limits; prompt larger than model context window; OpenAI service instability.","solutions":["Read str(e) in the message to identify the root cause (auth, rate limit, context length, etc.)","Verify the model API key, base_url and model name in the model configuration","Check rate limits/quota on the provider account and add backoff for 429s","Validate that prompt + history fits the model's context window","Catch ThirdPartyException upstream and surface a user-friendly message instead of the raw provider error"],"exampleFix":"// before\nexcept Exception as e:\n    logger.error(f\"The request for a large model failed：{e}\")\n    raise ThirdPartyException(str(e))\n// after\nexcept Exception as e:\n    logger.error(f\"The request for a large model failed：{e}\")\n    raise ThirdPartyException(msg=f\"{e} (large model request failure)\") from e","handlingStrategy":"try-catch","validationCode":"def llm_config_ready(cfg) -> bool:\n    return bool(cfg.get(\"api_key\")) and bool(cfg.get(\"model\")) and bool(cfg.get(\"base_url\"))","typeGuard":null,"tryCatchPattern":"try:\n    async for res, done in llm.stream_chat(messages):\n        yield res, done\nexcept ThirdPartyException as e:\n    logger.error(f\"LLM stream failed: {e}\")\n    yield StreamChunk(error=str(e)), True","preventionTips":["Validate model config (key, base_url, model name) at startup","Track token usage and enforce context limits before calling","Add backoff/retry for provider rate limits","Log full exception type, not just str(e), for diagnosis"],"tags":["llm","openai","streaming"],"backgroundTag":"upstream-api-error","analyzedSha":"5e758547a83371a5a4b29dadf4ac03e8dd527635","analyzedAt":"2026-09-12T08:03:51.356Z","contentChangedAt":"2026-09-12T08:03:51.356Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}