{"record":{"id":"f6401f9fdfb68915","repo":"iflytek/astron-agent","slug":"audit-output-error","errorCode":"AUDIT_OUTPUT_ERROR","errorMessage":"Audit result abnormal: {resp}","messagePattern":"Audit result abnormal: (.+?)","errorType":"error_code","errorClass":"CustomException","httpStatus":null,"severity":"error","filePath":"core/workflow/infra/audit_system/audit_api/iflytek/ifly_audit_api.py","lineNumber":422,"sourceCode":"        :param uid: User identifier for audit context\n        :param kwargs: Additional keyword arguments\n        :raises CustomException: If audit result indicates unsafe content\n        \"\"\"\n        payload = {\n            \"intention\": \"dialog\",\n            \"stage\": stage.value,\n            \"content\": content,\n            \"pindex\": pindex,\n            \"is_pending\": is_pending,\n            \"is_stage_end\": is_stage_end,\n            \"is_end\": is_end,\n            \"chat_sid\": chat_sid,\n        }\n        resp = await self._post(\n            \"/audit/v3/aichat/output\", payload, span, chat_app_id, uid\n        )\n        if resp.get(\"data\", {}).get(\"action\") != ActionEnum.NONE:\n            raise CustomException(\n                CodeEnum.AUDIT_OUTPUT_ERROR,\n                cause_error=f\"Audit result abnormal: {resp}\",\n            )\n\n    async def input_media(self, text: str, **kwargs: Any) -> None:\n        \"\"\"\n        In LLM content security scenarios, filter, detect and identify user input text,\n        images, videos, documents, etc., and process and respond accordingly based on security policies.\n        :param text: Text content to be processed\n        :param kwargs: Additional keyword arguments\n        :return: None\n        \"\"\"\n        # path = f\"/audit/v3/aichat/inputMedia\"\n\n        # TODO: To be implemented\n        raise NotImplementedError(\"IFlyAuditAPI.input_media is not implemented yet\")\n\n    async def output_media(self, text: str, **kwargs: Any) -> None:","sourceCodeStart":404,"sourceCodeEnd":440,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/infra/audit_system/audit_api/iflytek/ifly_audit_api.py#L404-L440","documentation":"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.","triggerScenarios":"Calling output_text(content, chat_sid, chat_sid, ...) where the audit API returns SUCCESS but data.action != NONE for the model-generated text.","commonSituations":"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.","solutions":["Inspect the response 'data' payload in the message to see the audit action and hit reasons.","In the caller, catch this and replace/withhold the model output instead of streaming it to the user.","Tune output-side audit rules in the IFlyTek console if legitimate responses are being flagged.","Log the flagged content (compliance-permitting) to refine prompts or add pre-filters."],"exampleFix":"// before: raw raise propagates to user\nif resp.get(\"data\", {}).get(\"action\") != ActionEnum.NONE:\n    raise CustomException(CodeEnum.AUDIT_OUTPUT_ERROR, ...)\n// after: caller handles blocked output\ntry:\n    await audit_api.output_text(answer, chat_sid, span)\nexcept CustomException as e:\n    if e.code == CodeEnum.AUDIT_OUTPUT_ERROR:\n        answer = \"Sorry, I cannot provide that content.\"\n    else:\n        raise","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"def output_blocked(resp: dict) -> bool:\n    return isinstance(resp, dict) and resp.get('data', {}).get('action') != ActionEnum.NONE","tryCatchPattern":"try:\n    await audit_api.output_text(answer, chat_sid, span)\nexcept CustomException as e:\n    if e.code == CodeEnum.AUDIT_OUTPUT_ERROR:\n        answer = FALLBACK_SAFE_REPLY\n    else:\n        raise","preventionTips":["Always audit LLM output before streaming it to users","Prepare a safe fallback reply for blocked generations","Log flagged outputs to tune prompts and rules"],"tags":["audit","content-moderation","llm-output","policy-violation"],"backgroundTag":"content-moderation-blocked","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"}