browser-use/browser-use · error · ValueError

Unknown message type: {type(message)}

Error message

Unknown message type: {type(message)}

What it means

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.

Source

Thrown at browser_use/llm/aws/serializer.py:234

			if message.content is not None:
				content_blocks.extend(AWSBedrockMessageSerializer._serialize_assistant_content(message.content))

			# Add tool use blocks if present
			if message.tool_calls:
				for tool_call in message.tool_calls:
					content_blocks.append(AWSBedrockMessageSerializer._serialize_tool_call(tool_call))

			# AWS Bedrock requires at least one content block
			if not content_blocks:
				content_blocks = [{'text': ''}]

			return {
				'role': 'assistant',
				'content': content_blocks,
			}

		else:
			raise ValueError(f'Unknown message type: {type(message)}')

	@staticmethod
	def serialize_messages(messages: list[BaseMessage]) -> tuple[list[dict[str, Any]], list[dict[str, Any]] | None]:
		"""
		Serialize a list of messages, extracting any system message.

		Returns:
			Tuple of (bedrock_messages, system_message) where system_message is extracted
			from any SystemMessage in the list.
		"""
		bedrock_messages: list[dict[str, Any]] = []
		system_message: list[dict[str, Any]] | None = None

		for message in messages:
			if isinstance(message, SystemMessage):
				# Extract system message content
				system_message = AWSBedrockMessageSerializer._serialize_system_content(message.content)
			else:

View on GitHub (pinned to 6c73fced2f)

Solutions

  1. Pass only browser-use's own BaseMessage subclasses (SystemMessage, HumanMessage, AIMessage, ToolMessage) as returned by its views
  2. Reuse history objects produced by the agent instead of constructing foreign message types
  3. Check for version drift: reinstall browser-use so its expected message classes match

Example fix

```python
# before
msgs = [{'role': 'user', 'content': 'hi'}]

# after
from browser_use.llm.messages import UserMessage
msgs = [UserMessage(content='hi')]
```
Defensive patterns

Strategy: type-guard

Validate before calling

```python
from browser_use.llm.messages import BaseMessage
def all_serializable(msgs) -> bool:
    return all(isinstance(m, BaseMessage) for m in msgs)
```

Type guard

```python
from browser_use.llm.messages import BaseMessage
def is_base_message(m: object) -> bool:
    return isinstance(m, BaseMessage)
```

Prevention

When it happens

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

Common situations: Mixing browser-use versions with a different installed langchain package; building histories by hand with dicts or strings; forked message classes.

Related errors


AI-assisted analysis of browser-use/browser-use@6c73fced2f (2026-08-14). Data as JSON: /api/errors/c27f47f520aa5368. Report an issue: GitHub.