{"record":{"id":"f011fa64e88ca46b","repo":"iflytek/astron-agent","slug":"spark-quick-repair-error","errorCode":"SPARK_QUICK_REPAIR_ERROR","errorMessage":"Sensitive content detected, LLM did not find function_call field","messagePattern":"Sensitive content detected, LLM did not find function_call field","errorType":"error_code","errorClass":"CustomException","httpStatus":null,"severity":"warning","filePath":"core/workflow/infra/providers/llm/iflytek_spark/spark_fc_llm.py","lineNumber":116,"sourceCode":"        :return: Tuple containing (function_name, token_usage, arguments)\n        \"\"\"\n        while True:\n            try:\n                msg = json.loads(await ws_handle.recv())\n                await span.add_info_events_async(\n                    {\"function_call_recv\": json.dumps(msg, ensure_ascii=False)}\n                )\n                code = msg[\"header\"][\"code\"]\n                if code != 0:\n                    raise CustomException(\n                        err_code=CodeConvert.sparkCode(code),\n                        cause_error=json.dumps(msg, ensure_ascii=False),\n                    )\n                status = msg[\"header\"][\"status\"]\n                llm_service_sid = msg[\"header\"][\"sid\"]\n                # Check if it's a quick repair: if the last character of sid is '1', it's a quick repair\n                if llm_service_sid[-1] == \"1\":\n                    raise CustomException(\n                        err_code=CodeEnum.SPARK_QUICK_REPAIR_ERROR,\n                        err_msg=\"Sensitive content detected, LLM did not find function_call field\",\n                        cause_error=\"Sensitive content detected, LLM did not find function_call field\",\n                    )\n                if status != 2:\n                    continue\n                token_usage = msg[\"payload\"][\"usage\"][\"text\"]\n                if \"function_call\" not in msg[\"payload\"][\"choices\"][\"text\"][0]:\n                    raise CustomException(\n                        err_code=CodeEnum.SPARK_FUNCTION_NOT_CHOICE_ERROR,\n                        err_msg=\"Cannot find function_call field in LLM response\",\n                        cause_error=\"Cannot find function_call field in LLM response\",\n                    )\n\n                name = msg[\"payload\"][\"choices\"][\"text\"][0][\"function_call\"][\"name\"]\n                arguments = msg[\"payload\"][\"choices\"][\"text\"][0][\"function_call\"][\n                    \"arguments\"\n                ]","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/iflytek/astron-agent/blob/5e758547a83371a5a4b29dadf4ac03e8dd527635/core/workflow/infra/providers/llm/iflytek_spark/spark_fc_llm.py#L98-L134","documentation":"Raised by SparkFcLLM._recv_messages when the Spark function-call response's message sid ends with '1', which per the Spark API indicates a 'quick repair' — the server-side content auditor intercepted the request and the LLM produced no function_call. The provider converts this into a SPARK_QUICK_REPAIR_ERROR stating sensitive content was detected. It is a content-compliance rejection, not a transport or code bug.","triggerScenarios":"Calling SparkFcLLM via async_call_spark_fc with user/assistant message content that Spark's auditing flags as sensitive; the final received frame's header.sid[-1] == '1' triggers the check at spark_fc_llm.py:115 before function_call extraction.","commonSituations":"End users submitting politically sensitive, violent, or otherwise policy-violating prompts in a tool-calling workflow; prompts containing sensitive keywords in Chinese regulatory context; audit level 'default' in the payload's parameter.chat.auditing being strict for the deployment region.","solutions":["Treat as an expected user-content rejection: catch SPARK_QUICK_REPAIR_ERROR and return a polite 'content not allowed' response to the end user instead of retrying.","Review the offending user input for sensitive keywords and add upstream input moderation/filtering before calling the FC LLM.","If false positives occur, review Spark console content-audit settings/patch_id configuration and adjust the auditing parameter or escalate to iFlytek support.","Sanitize or truncate user content (strip flagged segments) and retry once with a compliance-safe reformulation."],"exampleFix":"// before\nname, usage, args = await async_call_spark_fc(messages, functions)\n// after\ntry:\n    name, usage, args = await async_call_spark_fc(messages, functions)\nexcept CustomException as e:\n    if e.err_code == CodeEnum.SPARK_QUICK_REPAIR_ERROR:\n        return sanitize_refusal_response(messages)  # content was rejected by Spark auditing\n    raise","handlingStrategy":"try-catch","validationCode":"SENSITIVE_HINTS = (\"politics\", \"violence\", \"porn\", ...)  # plug in your moderation list\ndef screen_user_input(text: str) -> bool:\n    return not any(h in text.lower() for h in SENSITIVE_HINTS)\n# call before async_call_spark_fc: if not screen_user_input(user_text): return refusal_response()","typeGuard":"def is_spark_quick_repair(e: BaseException) -> bool:\n    return isinstance(e, CustomException) and e.err_code == CodeEnum.SPARK_QUICK_REPAIR_ERROR","tryCatchPattern":"try:\n    name, usage, args = await async_call_spark_fc(messages, functions, span)\nexcept CustomException as e:\n    if e.err_code == CodeEnum.SPARK_QUICK_REPAIR_ERROR:\n        return FunctionCallResult(status=\"content_rejected\", message=\"Your request was blocked by content moderation\")\n    raise  # do not retry; retrying flagged content will be rejected again","preventionTips":["Run upstream input moderation/filtering before sending user content to Spark function calling.","Never blindly retry this error — the same content will be flagged again; return a refusal to the user.","Track quick-repair occurrences per user/prompt to tune false-positive thresholds with iFlytek support.","Review the auditing parameter (parameter.chat.auditing) and patch_id configuration if legitimate traffic is being rejected."],"tags":["content-moderation","spark","llm","function-calling","compliance"],"backgroundTag":"content-moderation-rejected","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"}