apache/seatunnel · error · RuntimeError

Bedrock Mantle model refused the request

Error message

Bedrock Mantle model refused the request: {refusal}

What it means

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.

Solutions

  1. Rephrase the prompt to remove content that triggers the model's safety policy
  2. Review and relax Bedrock guardrail / moderation settings if this is a false positive
  3. Catch the RuntimeError, inspect the refusal text, and fall back to a different model or provider

Example fix

// before
reply = provider.chat(messages)
// after
try:
    reply = provider.chat(messages)
except RuntimeError as e:
    if "refused the request" in str(e):
        reply = fallback_provider.chat(sanitize(messages))
    else:
        raise
Defensive patterns

Strategy: try-catch

Validate before calling

def is_safe_prompt(prompt: str) -> bool:
    banned = ["weapon", "exploit", "malware"]
    return not any(b in prompt.lower() for b in banned)

Type guard

def is_refusal_error(e: BaseException) -> bool:
    return isinstance(e, RuntimeError) and "refused the request" in str(e)

Try / catch

try:
    reply = provider.chat(messages)
except RuntimeError as e:
    if "refused the request" in str(e):
        handle_refusal(str(e).split(": ", 1)[1])
    else:
        raise

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/793208ac073d9626. Report an issue: GitHub.

Appendix: source

Thrown at seatunnel-cli/seatunnel_cli/llm_provider.py:1142

            "store": False,
        }
        if system:
            kwargs["instructions"] = system
        if tools:
            kwargs["tools"] = self._to_responses_tools(tools)

        response = client.responses.create(**kwargs)
        self._raise_on_terminal_status(response)

        content: list[dict] = []
        has_tool_use = False
        for item in response.output:
            itype = getattr(item, "type", "")
            if itype == "message":
                for part in getattr(item, "content", []) or []:
                    if getattr(part, "type", "") == "refusal":
                        refusal = getattr(part, "refusal", "") or ""
                        raise RuntimeError(
                            f"Bedrock Mantle model refused the request: {refusal}")
                    text = getattr(part, "text", None)
                    if text:
                        content.append({"text": text})
            elif itype == "function_call":
                has_tool_use = True
                try:
                    parsed = json.loads(item.arguments or "{}")
                except (json.JSONDecodeError, TypeError):
                    parsed = {}
                content.append({
                    "toolUse": {
                        "toolUseId": item.call_id,
                        "name": item.name,
                        "input": parsed,
                    }
                })
            elif itype == "reasoning":

View on GitHub (pinned to cf67b549a7)