{"record":{"id":"793208ac073d9626","repo":"apache/seatunnel","slug":"bedrock-mantle-model-refused-the-request-refusal","errorCode":null,"errorMessage":"Bedrock Mantle model refused the request: {refusal}","messagePattern":"Bedrock Mantle model refused the request: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"seatunnel-cli/seatunnel_cli/llm_provider.py","lineNumber":1142,"sourceCode":"            \"store\": False,\n        }\n        if system:\n            kwargs[\"instructions\"] = system\n        if tools:\n            kwargs[\"tools\"] = self._to_responses_tools(tools)\n\n        response = client.responses.create(**kwargs)\n        self._raise_on_terminal_status(response)\n\n        content: list[dict] = []\n        has_tool_use = False\n        for item in response.output:\n            itype = getattr(item, \"type\", \"\")\n            if itype == \"message\":\n                for part in getattr(item, \"content\", []) or []:\n                    if getattr(part, \"type\", \"\") == \"refusal\":\n                        refusal = getattr(part, \"refusal\", \"\") or \"\"\n                        raise RuntimeError(\n                            f\"Bedrock Mantle model refused the request: {refusal}\")\n                    text = getattr(part, \"text\", None)\n                    if text:\n                        content.append({\"text\": text})\n            elif itype == \"function_call\":\n                has_tool_use = True\n                try:\n                    parsed = json.loads(item.arguments or \"{}\")\n                except (json.JSONDecodeError, TypeError):\n                    parsed = {}\n                content.append({\n                    \"toolUse\": {\n                        \"toolUseId\": item.call_id,\n                        \"name\": item.name,\n                        \"input\": parsed,\n                    }\n                })\n            elif itype == \"reasoning\":","sourceCodeStart":1124,"sourceCodeEnd":1160,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-cli/seatunnel_cli/llm_provider.py#L1124-L1160","documentation":"Raised by the Bedrock Mantle (Responses-API) provider's chat() when the model returns a refusal content part instead of text. The library surfaces the model's own refusal text verbatim so the caller knows the request was rejected on content-policy grounds, not due to a transport or auth failure.","triggerScenarios":"Calling chat() against the Bedrock Mantle provider and iterating response.output when a part has type == \"refusal\"; the RuntimeError fires immediately with the refusal string embedded.","commonSituations":"Prompts that trip the model's safety filters (harmful, illegal, or policy-violating content); over-aggressive guardrail configurations on the Bedrock side; prompts that look like injection attempts.","solutions":["Rephrase the prompt to remove content that triggers the model's safety policy","Review and relax Bedrock guardrail / moderation settings if this is a false positive","Catch the RuntimeError, inspect the refusal text, and fall back to a different model or provider"],"exampleFix":"// before\nreply = provider.chat(messages)\n// after\ntry:\n    reply = provider.chat(messages)\nexcept RuntimeError as e:\n    if \"refused the request\" in str(e):\n        reply = fallback_provider.chat(sanitize(messages))\n    else:\n        raise","handlingStrategy":"try-catch","validationCode":"def is_safe_prompt(prompt: str) -> bool:\n    banned = [\"weapon\", \"exploit\", \"malware\"]\n    return not any(b in prompt.lower() for b in banned)","typeGuard":"def is_refusal_error(e: BaseException) -> bool:\n    return isinstance(e, RuntimeError) and \"refused the request\" in str(e)","tryCatchPattern":"try:\n    reply = provider.chat(messages)\nexcept RuntimeError as e:\n    if \"refused the request\" in str(e):\n        handle_refusal(str(e).split(\": \", 1)[1])\n    else:\n        raise","preventionTips":["Sanitize user prompts before sending to the model","Keep Bedrock guardrails configured deliberately and review refusals for false positives","Provide an alternate model/provider fallback for refused requests"],"tags":["llm","bedrock","content-refusal","runtime"],"backgroundTag":"upstream-api-error","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}