{"record":{"id":"442f2d9862f0f23d","repo":"apache/seatunnel","slug":"bedrock-mantle-response-ended-with-status-status","errorCode":null,"errorMessage":"Bedrock Mantle response ended with status '{status}'{detail}","messagePattern":"Bedrock Mantle response ended with status '(.+?)'(.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"seatunnel-cli/seatunnel_cli/llm_provider.py","lineNumber":1098,"sourceCode":"    def _raise_on_terminal_status(response) -> None:\n        \"\"\"Fail loudly on non-completed terminal states.\n\n        Bedrock Mantle reports truncation/filtering/model errors in-band via\n        ``status`` + ``incomplete_details``/``error`` rather than transport\n        errors; treating those as success would hand truncated configs to\n        the agent loop as if they were complete.\n        \"\"\"\n        status = getattr(response, \"status\", None)\n        if status in (None, \"completed\"):\n            return\n        detail = \"\"\n        incomplete = getattr(response, \"incomplete_details\", None)\n        if incomplete is not None:\n            detail = f\" ({getattr(incomplete, 'reason', '') or incomplete})\"\n        error = getattr(response, \"error\", None)\n        if error is not None:\n            detail += f\" error: {getattr(error, 'message', '') or error}\"\n        raise RuntimeError(\n            f\"Bedrock Mantle response ended with status '{status}'{detail}\")\n\n    def chat(\n        self,\n        messages: list[dict],\n        system: str = \"\",\n        model: str | None = None,\n        temperature: float = 0.3,\n        max_tokens: int = 4096,\n        tools: list[dict] | None = None,\n    ) -> dict:\n        \"\"\"Send a non-streaming Responses API request.\n\n        Requests are sent with ``store=False`` so Bedrock does not retain\n        prompt/response data server-side (its default is 30-day retention).\n        Reasoning output items are preserved verbatim in the returned\n        history so subsequent turns can replay them. Non-``completed``\n        terminal statuses and refusals raise ``RuntimeError`` instead of","sourceCodeStart":1080,"sourceCodeEnd":1116,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-cli/seatunnel_cli/llm_provider.py#L1080-L1116","documentation":"The Bedrock Mantle provider inspects the final streaming/response status and treats any terminal non-success status (e.g. 'incomplete', 'failed') as a fatal condition, raising RuntimeError with the status plus any incomplete_details.reason or error.message returned by the API.","triggerScenarios":"_raise_on_terminal_status (invoked from chat and chat_stream) receives a response whose terminal status is not successful — the Mantle run ended with status like 'incomplete' or 'failed', optionally with incomplete_details or an error object.","commonSituations":"Response hit a content/length filter (incomplete_details.reason) causing truncation; upstream Bedrock error returned an error payload; long streaming run terminated early by service-side limits.","solutions":["Read the status and detail in the message: fix the underlying cause reported by incomplete_details or error.message","If the reason is a content/length limit, reduce prompt size or adjust max output tokens and retry","Check AWS Bedrock service health/quota and region configuration (AWS_REGION), then retry the request","Upgrade the aws-bedrock-token-generator/openai packages if the API response shape changed"],"exampleFix":"// before\nresp = provider.chat(messages)  # RuntimeError: status 'incomplete'\n// after\nresp = provider.chat(messages, max_tokens=2048)  # fit within limits; inspect resp status","handlingStrategy":"retry","validationCode":"# Check status before consuming output\nterminal = getattr(response, 'status', None)\nif terminal in ('incomplete', 'failed'):\n    handle_mantle_failure(response)","typeGuard":null,"tryCatchPattern":"try:\n    resp = provider.chat(messages)\nexcept RuntimeError as e:\n    # e.g. status 'incomplete' with incomplete_details.reason\n    log.warning('Mantle run ended badly: %s', e)\n    resp = retry_with_smaller_prompt(messages)","preventionTips":["Keep prompts and max output tokens within service limits","Set AWS_REGION correctly for your Bedrock endpoint","Inspect incomplete_details.reason and error.message early in development","Add retry with backoff for transient service-side failures"],"tags":["python","llm","aws","bedrock","streaming"],"backgroundTag":"http-error-response","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"}