Skip to content

Conversation

bnovik0v
Copy link
Contributor

Adds image content support to LangGraph message serialization so that messages containing images are properly handled by LangChain/LangGraph pipelines.

  • Introduced _serialize_chat_message_content() to handle multimodal ChatMessage content:

    • Text-only → returns string (backward-compatible).

    • Multimodal → returns list of blocks:

      • text → {"type": "text", "text": "..."}
      • image → {"type": "image_url", "image_url": {"url": "<image_url>"}}
  • Updated LangGraphStream._chat_ctx_to_state() to use the serializer for AIMessage, HumanMessage, and SystemMessage.

Why
Previously, image content wasn’t serialized into LangChain’s multimodal format, preventing proper handling in graph pipelines.

Copy link
Member

@davidzhao davidzhao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the change itself looks good. could you fix the type errors please?

@bnovik0v bnovik0v requested a review from davidzhao September 16, 2025 10:08
@bnovik0v
Copy link
Contributor Author

the change itself looks good. could you fix the type errors please?

I've fixed the type errors in the latest commit, could you take another look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants