{"record":{"id":"5c3d2c975144bf98","repo":"BerriAI/litellm","slug":"bedrockexception-error-str-pass-in-default-u","errorCode":null,"errorMessage":"BedrockException - {error_str}\n. Pass in default user message via `completion(..,user_continue_message=)` or enable `litellm.modify_params=True`.\nFor Proxy: do via `litellm_settings::modify_params: True` or user_continue_message under `litellm_params`","messagePattern":"BedrockException - (.+?)\n\\. Pass in default user message via `completion\\(\\.\\.,user_continue_message=\\)` or enable `litellm\\.modify_params=True`\\.\nFor Proxy: do via `litellm_settings::modify_params: True` or user_continue_message under `litellm_params`","errorType":"exception","errorClass":"BadRequestError","httpStatus":400,"severity":"error","filePath":"litellm/litellm_core_utils/exception_mapping_utils.py","lineNumber":852,"sourceCode":"            model=model,\n            llm_provider=\"bedrock\",\n        )\n    elif \"Conversation blocks and tool result blocks cannot be provided in the same turn.\" in error_str:\n        raise BadRequestError(\n            message=f\"BedrockException - {error_str}\\n. Enable 'litellm.modify_params=True' (for PROXY do: `litellm_settings::modify_params: True`) to insert a dummy assistant message and fix this error.\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"Malformed input request\" in error_str:\n        raise BadRequestError(\n            message=f\"BedrockException - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"A conversation must start with a user message.\" in error_str:\n        raise BadRequestError(\n            message=f\"BedrockException - {error_str}\\n. Pass in default user message via `completion(..,user_continue_message=)` or enable `litellm.modify_params=True`.\\nFor Proxy: do via `litellm_settings::modify_params: True` or user_continue_message under `litellm_params`\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif (\n        \"Unable to locate credentials\" in error_str\n        or \"The security token included in the request is invalid\" in error_str\n    ):\n        raise AuthenticationError(\n            message=f\"BedrockException Invalid Authentication - {error_str}\",\n            model=model,\n            llm_provider=\"bedrock\",\n            response=getattr(original_exception, \"response\", None),\n        )\n    elif \"AccessDeniedException\" in error_str:\n        raise PermissionDeniedError(\n            message=f\"BedrockException PermissionDeniedError - {error_str}\",","sourceCodeStart":834,"sourceCodeEnd":870,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/litellm_core_utils/exception_mapping_utils.py#L834-L870","documentation":"Bedrock-specific: BadRequestError raised when the error text contains 'A conversation must start with a user message.' — your first non-system message was not a user message (typically an assistant message first). The error message offers two fixes: pass user_continue_message to completion() or enable litellm.modify_params so LiteLLM prepends a default user message.","triggerScenarios":"Sending a transcript that starts with an assistant turn — e.g. prefilled assistant responses, resuming a conversation from a saved history whose first user turn was dropped, or trimming that removed the leading user message.","commonSituations":"Prefill-style prompting (assistant-first), agent loops that persist and reload history with the opening user turn stripped, or log-replay tools replaying partial transcripts.","solutions":["Pass user_continue_message: litellm.completion(..., user_continue_message={\"role\": \"user\", \"content\": \"...\"}).","Or set litellm.modify_params = True (proxy: litellm_settings.modify_params: true) to auto-insert a default user message.","Or fix the history: ensure messages[0] after the optional system message has role 'user'."],"exampleFix":"# before\nresp = litellm.completion(model=\"bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0\", messages=[{\"role\": \"assistant\", \"content\": \"Sure, here is...\"}])\n\n# after\nresp = litellm.completion(\n    model=\"bedrock/anthropic.claude-3-5-sonnet-20240620-v1:0\",\n    messages=[{\"role\": \"assistant\", \"content\": \"Sure, here is...\"}],\n    user_continue_message={\"role\": \"user\", \"content\": \"continue\"},\n)","handlingStrategy":"validation","validationCode":"def starts_with_user_message(messages: list) -> bool:\n    non_system = [m for m in messages if m.get(\"role\") != \"system\"]\n    return bool(non_system) and non_system[0].get(\"role\") == \"user\"","typeGuard":"import litellm\n\ndef is_bedrock_first_turn_error(e: BaseException) -> bool:\n    return isinstance(e, litellm.BadRequestError) and \"must start with a user message\" in str(e)","tryCatchPattern":"try:\n    resp = litellm.completion(model=\"bedrock/...\", messages=msgs)\nexcept litellm.BadRequestError as e:\n    if \"must start with a user message\" in str(e):\n        msgs = [{\"role\": \"user\", \"content\": \"continue\"}, *msgs]\n        resp = litellm.completion(model=\"bedrock/...\", messages=msgs)\n    else:\n        raise","preventionTips":["Pass user_continue_message when replaying assistant-first or prefilled histories.","Or enable litellm.modify_params = True to let litellm insert the default user message.","When trimming histories, never drop the opening user turn."],"tags":["bedrock","message-order","converse-api","litellm"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}