image gen format fixes#91
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the gateway’s chat-message handling to better support multimodal (vision-style) OpenAI content blocks by preserving list-of-parts user content instead of flattening it into a single string, and aligns request hashing + tests with that behavior.
Changes:
- Preserve user
contentprovided as a list of parts (e.g.,text+image_url) when converting OpenAI-format messages to LangChain messages. - Stop stringifying non-string user content in
_chat_request_to_dict, enabling canonical JSON hashing for list-of-parts requests. - Update/extend unit tests to assert list-of-parts preservation.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
tee_gateway/llm_backend.py |
Preserves multimodal user content lists via normalization rather than concatenating into a string. |
tee_gateway/controllers/chat_controller.py |
Keeps user message content as-is when building the canonical hash dictionary. |
tee_gateway/test/test_tee_core.py |
Updates convert_messages tests to validate list-of-parts preservation for user content. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
571
to
+575
| def test_user_content_as_list_of_parts(self): | ||
| """Multimodal content parts should be concatenated into a single string.""" | ||
| """Multimodal content parts should be preserved for vision-capable models.""" | ||
| content = [ | ||
| {"type": "text", "text": "Hello world"}, | ||
| { |
Comment on lines
911
to
915
| messages.append( | ||
| { | ||
| "role": "user", | ||
| "content": msg.content | ||
| if isinstance(msg.content, str) | ||
| else str(msg.content), | ||
| "content": msg.content, | ||
| } |
Comment on lines
361
to
364
| elif role == "user": | ||
| # content may be a string or a list of content parts; handle both | ||
| if isinstance(content, list): | ||
| content = "".join( | ||
| part.get("text", "") if isinstance(part, dict) else str(part) | ||
| for part in content | ||
| ) | ||
| content = _normalize_user_content_parts(content) | ||
| langchain_messages.append(HumanMessage(content=content)) |
adambalogh
previously approved these changes
Jun 3, 2026
adambalogh
approved these changes
Jun 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.