[PR #4863] fix: preserve usage_metadata in streamed messages when using multiplestream modes #4109

Closed
opened 2026-02-20 17:49:40 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langchain-ai/langgraph/pull/4863

State: closed
Merged: No


When using stream_mode=["values", "messages"], usage_metadata was being lost in the streamed messages. This fix ensures that usage_metadata is preserved by copying it into additional_kwargs in the StreamMessagesHandler._emit method. A test is added to verify this behavior.

Fix https://github.com/langchain-ai/langgraph/issues/4848

Added test cases for possible fix so to understand that it returns messages and values as response

**Original Pull Request:** https://github.com/langchain-ai/langgraph/pull/4863 **State:** closed **Merged:** No --- When using stream_mode=["values", "messages"], usage_metadata was being lost in the streamed messages. This fix ensures that usage_metadata is preserved by copying it into additional_kwargs in the StreamMessagesHandler._emit method. A test is added to verify this behavior. Fix https://github.com/langchain-ai/langgraph/issues/4848 Added test cases for possible fix so to understand that it returns messages and values as response
yindo added the pull-request label 2026-02-20 17:49:40 -05:00
yindo closed this issue 2026-02-20 17:49:40 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraph#4109