iflytek/astron-agent · error · CustomException

AUDIT_OUTPUT_ERROR

AUDIT_OUTPUT_ERROR

Error message

Audit result abnormal: {resp}

What it means

Raised by output_text after a successful audit request when the response's data.action is not ActionEnum.NONE — the audit service flagged the LLM's output text. The library raises AUDIT_OUTPUT_ERROR with the full response, meaning generated content failed the output-side content-safety check and must not be delivered as-is.

Solutions

  1. Inspect the response 'data' payload in the message to see the audit action and hit reasons.
  2. In the caller, catch this and replace/withhold the model output instead of streaming it to the user.
  3. Tune output-side audit rules in the IFlyTek console if legitimate responses are being flagged.
  4. Log the flagged content (compliance-permitting) to refine prompts or add pre-filters.

Example fix

// before: raw raise propagates to user
if resp.get("data", {}).get("action") != ActionEnum.NONE:
    raise CustomException(CodeEnum.AUDIT_OUTPUT_ERROR, ...)
// after: caller handles blocked output
try:
    await audit_api.output_text(answer, chat_sid, span)
except CustomException as e:
    if e.code == CodeEnum.AUDIT_OUTPUT_ERROR:
        answer = "Sorry, I cannot provide that content."
    else:
        raise
Defensive patterns

Strategy: try-catch

Type guard

def output_blocked(resp: dict) -> bool:
    return isinstance(resp, dict) and resp.get('data', {}).get('action') != ActionEnum.NONE

Try / catch

try:
    await audit_api.output_text(answer, chat_sid, span)
except CustomException as e:
    if e.code == CodeEnum.AUDIT_OUTPUT_ERROR:
        answer = FALLBACK_SAFE_REPLY
    else:
        raise

Prevention

When it happens

Trigger: Calling output_text(content, chat_sid, chat_sid, ...) where the audit API returns SUCCESS but data.action != NONE for the model-generated text.

Common situations: LLM generations containing sensitive content, hallucinated policy-violating text, overly strict output rules blocking benign replies, or enum drift making a passing response compare unequal to ActionEnum.NONE.

Related errors


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

Appendix: source

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

        :param uid: User identifier for audit context
        :param kwargs: Additional keyword arguments
        :raises CustomException: If audit result indicates unsafe content
        """
        payload = {
            "intention": "dialog",
            "stage": stage.value,
            "content": content,
            "pindex": pindex,
            "is_pending": is_pending,
            "is_stage_end": is_stage_end,
            "is_end": is_end,
            "chat_sid": chat_sid,
        }
        resp = await self._post(
            "/audit/v3/aichat/output", payload, span, chat_app_id, uid
        )
        if resp.get("data", {}).get("action") != ActionEnum.NONE:
            raise CustomException(
                CodeEnum.AUDIT_OUTPUT_ERROR,
                cause_error=f"Audit result abnormal: {resp}",
            )

    async def input_media(self, text: str, **kwargs: Any) -> None:
        """
        In LLM content security scenarios, filter, detect and identify user input text,
        images, videos, documents, etc., and process and respond accordingly based on security policies.
        :param text: Text content to be processed
        :param kwargs: Additional keyword arguments
        :return: None
        """
        # path = f"/audit/v3/aichat/inputMedia"

        # TODO: To be implemented
        raise NotImplementedError("IFlyAuditAPI.input_media is not implemented yet")

    async def output_media(self, text: str, **kwargs: Any) -> None:

View on GitHub (pinned to 5e758547a8)