iflytek/astron-agent · error · ThirdPartyException

(large model request failure)

Error message

{str(e)} (large model request failure)

What it means

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.

Solutions

  1. Read str(e) in the message to identify the root cause (auth, rate limit, context length, etc.)
  2. Verify the model API key, base_url and model name in the model configuration
  3. Check rate limits/quota on the provider account and add backoff for 429s
  4. Validate that prompt + history fits the model's context window
  5. Catch ThirdPartyException upstream and surface a user-friendly message instead of the raw provider error

Example fix

// before
except Exception as e:
    logger.error(f"The request for a large model failed:{e}")
    raise ThirdPartyException(str(e))
// after
except Exception as e:
    logger.error(f"The request for a large model failed:{e}")
    raise ThirdPartyException(msg=f"{e} (large model request failure)") from e
Defensive patterns

Strategy: try-catch

Validate before calling

def llm_config_ready(cfg) -> bool:
    return bool(cfg.get("api_key")) and bool(cfg.get("model")) and bool(cfg.get("base_url"))

Try / catch

try:
    async for res, done in llm.stream_chat(messages):
        yield res, done
except ThirdPartyException as e:
    logger.error(f"LLM stream failed: {e}")
    yield StreamChunk(error=str(e)), True

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12). Data as JSON: /api/errors/94994035b1f98421. Report an issue: GitHub.

Appendix: source

Thrown at core/knowledge/llm/openai_llm.py:107

                        True if chunk.choices[0].finish_reason == "stop" else False
                    )
                    span_context.add_info_events(
                        {"LLM_OUTPUT": json.dumps(chunk.dict(), ensure_ascii=False)}
                    )

                    if finished:
                        if len(res.content) > 0:
                            yield res, False
                            res.content = ""
                            yield res, True
                        else:
                            res.content = ""
                            yield res, True
                    else:
                        yield res, False
        except Exception as e:
            logger.error(f"The request for a large model failed:{e}")
            raise ThirdPartyException(str(e))

View on GitHub (pinned to 5e758547a8)