browser-use
browser-use copied to clipboard
fix(llm/google): fix image handling in first user message with system text
When include_system_in_user=True, non-text content (images) in the first user message was not being serialized. Now properly handles mixed content by extracting image serialization logic into a helper method.
Summary by cubic
Fixes image handling in the Google Gemini serializer so images in the first user message are preserved when system text is included. Also ensures system text is inserted before the first part, including image-only messages.
-
Bug Fixes
- Preserve images and include system text in the first user message when include_system_in_user=True, even if it has no text parts.
-
Refactors
- Extracted image serialization into _serialize_image.
- Insert system text before the first part; simplified role detection and made content iteration safer.
Written for commit 8982da7d5cf3a38ca67332c89e822ef857f78a84. Summary will update automatically on new commits.