iflytek/astron-agent · error · AuditServiceException

9021

9021

Error message

审核服务异常

What it means

ifly_audit_api._post raises '审核服务异常' when the audit (content-moderation) HTTP call fails after retries — non-2xx status or transport error while POSTing to the moderation host. Called from input_text/output_text, so chat content could not be audited.

Solutions

  1. Check audit service availability and logs for the failing status code.
  2. Verify audit endpoint URL, app_id/uid credentials, and network access from core/common consumers.
  3. Increase RETRY_COUNT or add backoff if failures are transient.
  4. Confirm no firewall/proxy is blocking the audit host.
Defensive patterns

Strategy: try-catch

Try / catch

try:
    await audit_api.input_text(stage, content, pindex=pindex, span=span, ...)
except AuditServiceException as e:
    span.record_exception(e)
    logger.error("audit gateway returned non-200; failing open/closed per policy")

Prevention

When it happens

Trigger: `_post` receives `response.status != 200` on every retry attempt while calling the audit HTTP endpoint (from `input_text`/`output_text`).

Common situations: Audit gateway down or returning 5xx; wrong AUDIT_API URL/host config; gateway auth rejection returning 401/403; proxy or LB errors between services.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


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

Appendix: source

Thrown at core/common/audit_system/audit_api/iflytek/ifly_audit_api.py:156

            while True:
                async with aiohttp.ClientSession(timeout=timeout) as session:
                    try:
                        url = self._gen_req_url(f"{host}{path}", chat_app_id, uid)
                        span.add_info_event(
                            f"请求URL: {url}, 重试次数: {current_retry}/{RETRY_COUNT}"
                        )
                        async with session.post(url, json=payload) as response:
                            cause_error = (
                                f"状态码: {response.status}, "
                                f"响应内容: {await response.text()}"
                            )

                            if response.status != 200:
                                span.add_error_event(cause_error)
                                if current_retry < RETRY_COUNT:
                                    continue
                                else:
                                    raise AuditServiceException(*c9021)(cause_error)

                            resp_json = await response.json()
                            span.add_info_event(f"送审响应体: {resp_json}")

                            code = resp_json.get("code", -1)
                            if int(code) == 0:
                                return resp_json
                            if int(code) == 999999 and current_retry < RETRY_COUNT:
                                continue
                            else:
                                cause_error = (
                                    f"请求失败,状态码: {response.status}, "
                                    f"响应内容: {await response.text()}, "
                                    f"响应体: {resp_json}"
                                )
                                raise AuditServiceException(*c9021)(cause_error)

                    except (aiohttp.ClientError, asyncio.TimeoutError, Exception) as e:

View on GitHub (pinned to 5e758547a8)