iflytek/astron-agent · error · CustomException

AUDIT_INPUT_ERROR

AUDIT_INPUT_ERROR

Error message

Audit result abnormal: {resp}

What it means

Raised by input_text after a successful audit request when the response's data.action is not ActionEnum.NONE — i.e. the audit service flagged the input text and returned a moderation action (block/replace/review) instead of passing it. The library treats any non-NONE action as an input policy violation and raises AUDIT_INPUT_ERROR with the full response attached.

Solutions

  1. Read the response 'data' in the message to see which action and hit details the audit service returned.
  2. Surface a friendly content-policy message to the end user and reject or sanitize the offending input.
  3. Review the configured audit rule categories if benign content is being blocked; tune rules in the IFlyTek console.
  4. Verify ActionEnum values match the API contract so NONE is compared correctly.

Example fix

// before: treat every non-NONE action as a hard error
if resp.get("data", {}).get("action") != ActionEnum.NONE:
    raise CustomException(CodeEnum.AUDIT_INPUT_ERROR, ...)
// after: handle blocking action gracefully in caller
try:
    await audit_api.input_text(content, chat_sid, span)
except CustomException as e:
    if e.code == CodeEnum.AUDIT_INPUT_ERROR:
        return "Your message was blocked by content moderation."
    raise
Defensive patterns

Strategy: try-catch

Validate before calling

def input_precheck(content: str) -> bool:
    return bool(content) and len(content) <= MAX_AUDIT_TEXT_LEN

Type guard

def audit_blocked(resp: dict) -> bool:
    return isinstance(resp, dict) and resp.get('data', {}).get('action') not in (None, ActionEnum.NONE)

Try / catch

try:
    await audit_api.input_text(user_input, chat_sid, span)
except CustomException as e:
    if e.code == CodeEnum.AUDIT_INPUT_ERROR:
        return ModerationResult(blocked=True, detail=str(e))
    raise

Prevention

When it happens

Trigger: Calling input_text(content, chat_sid, ...) where the audit API returns code SUCCESS but data.action != NONE — the submitted user input tripped a content-safety rule.

Common situations: Users submitting text with sensitive/prohibited words, prompts that hit compliance rules, misconfigured audit rule packs that over-block benign content, or ActionEnum comparison mismatch after an SDK/enum version change.

Related errors


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

Appendix: source

Thrown at core/workflow/infra/audit_system/audit_api/iflytek/ifly_audit_api.py:370

        payload_resource_list = []
        if context_list:
            for ctx in context_list:
                if ctx.resource_list:
                    payload_resource_list.append(
                        res.dict() for res in ctx.resource_list
                    )
                payload_context_list.append(ctx.dict())

        if payload_context_list:
            payload["context_list"] = payload_context_list
        if payload_resource_list:
            payload["resource_list"] = payload_resource_list

        resp = await self._post(
            "/audit/v3/aichat/input", payload, span, chat_app_id, uid
        )
        if resp.get("data", {}).get("action") != ActionEnum.NONE:
            raise CustomException(
                CodeEnum.AUDIT_INPUT_ERROR,
                cause_error=f"Audit result abnormal: {resp}",
            )

    async def output_text(
        self,
        stage: Stage,
        content: str,
        pindex: int,
        span: Span,
        is_pending: Literal[0, 1],
        is_stage_end: Literal[0, 1],
        is_end: Literal[0, 1],
        chat_sid: str,
        chat_app_id: str = "",
        uid: str = "",
        **kwargs: Any,
    ) -> None:

View on GitHub (pinned to 5e758547a8)