{"record":{"id":"c27f47f520aa5368","repo":"browser-use/browser-use","slug":"unknown-message-type-type-message-c27f47","errorCode":null,"errorMessage":"Unknown message type: {type(message)}","messagePattern":"Unknown message type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"browser_use/llm/aws/serializer.py","lineNumber":234,"sourceCode":"\t\t\tif message.content is not None:\n\t\t\t\tcontent_blocks.extend(AWSBedrockMessageSerializer._serialize_assistant_content(message.content))\n\n\t\t\t# Add tool use blocks if present\n\t\t\tif message.tool_calls:\n\t\t\t\tfor tool_call in message.tool_calls:\n\t\t\t\t\tcontent_blocks.append(AWSBedrockMessageSerializer._serialize_tool_call(tool_call))\n\n\t\t\t# AWS Bedrock requires at least one content block\n\t\t\tif not content_blocks:\n\t\t\t\tcontent_blocks = [{'text': ''}]\n\n\t\t\treturn {\n\t\t\t\t'role': 'assistant',\n\t\t\t\t'content': content_blocks,\n\t\t\t}\n\n\t\telse:\n\t\t\traise ValueError(f'Unknown message type: {type(message)}')\n\n\t@staticmethod\n\tdef serialize_messages(messages: list[BaseMessage]) -> tuple[list[dict[str, Any]], list[dict[str, Any]] | None]:\n\t\t\"\"\"\n\t\tSerialize a list of messages, extracting any system message.\n\n\t\tReturns:\n\t\t\tTuple of (bedrock_messages, system_message) where system_message is extracted\n\t\t\tfrom any SystemMessage in the list.\n\t\t\"\"\"\n\t\tbedrock_messages: list[dict[str, Any]] = []\n\t\tsystem_message: list[dict[str, Any]] | None = None\n\n\t\tfor message in messages:\n\t\t\tif isinstance(message, SystemMessage):\n\t\t\t\t# Extract system message content\n\t\t\t\tsystem_message = AWSBedrockMessageSerializer._serialize_system_content(message.content)\n\t\t\telse:","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/browser-use/browser-use/blob/6c73fced2f6d45a11d88622fe56365a5fe18f28b/browser_use/llm/aws/serializer.py#L216-L252","documentation":"Raised by AWSBedrockMessageSerializer.serialize_message when the message object is not one of the recognized types (SystemMessage, HumanMessage, AIMessage, and their multi-modal content variants). The serializer dispatches on message type and has no handler for anything else.","triggerScenarios":"Passing a ChatMessage from a different library/version (e.g. langchain-core message classes that differ from the ones imported here), custom message subclasses, or None/str instead of BaseMessage instances.","commonSituations":"Mixing browser-use versions with a different installed langchain package; building histories by hand with dicts or strings; forked message classes.","solutions":["Pass only browser-use's own BaseMessage subclasses (SystemMessage, HumanMessage, AIMessage, ToolMessage) as returned by its views","Reuse history objects produced by the agent instead of constructing foreign message types","Check for version drift: reinstall browser-use so its expected message classes match"],"exampleFix":"```python\n# before\nmsgs = [{'role': 'user', 'content': 'hi'}]\n\n# after\nfrom browser_use.llm.messages import UserMessage\nmsgs = [UserMessage(content='hi')]\n```","handlingStrategy":"type-guard","validationCode":"```python\nfrom browser_use.llm.messages import BaseMessage\ndef all_serializable(msgs) -> bool:\n    return all(isinstance(m, BaseMessage) for m in msgs)\n```","typeGuard":"```python\nfrom browser_use.llm.messages import BaseMessage\ndef is_base_message(m: object) -> bool:\n    return isinstance(m, BaseMessage)\n```","tryCatchPattern":null,"preventionTips":["Build histories only from browser-use's own message classes","Never feed raw dicts or foreign-framework messages into LLM adapters","Keep browser-use and its message classes at one pinned version"],"tags":["aws","bedrock","serialization","messages","type-error"],"backgroundTag":null,"analyzedSha":"6c73fced2f6d45a11d88622fe56365a5fe18f28b","analyzedAt":"2026-08-14T19:42:40.557Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}