Skip to content

When streaming using stream mode of messages I get token-by-token messages and full message at the end #6153

Description

Checked other resources

  • This is a bug, not a usage question. For questions, please use the LangChain Forum (https://forum.langchain.com/).
  • I added a clear and detailed title that summarizes the issue.
  • I read what a minimal reproducible example is (https://stackoverflow.com/help/minimal-reproducible-example).
  • I included a self-contained, minimal example that demonstrates the issue INCLUDING all the relevant imports. The code run AS IS to reproduce the issue.

Example Code

for chunk_item in self.graph.stream(
    initial_state, config, stream_mode="messages"
):

Error Message and Stack Trace (if applicable)

Stream chunk: content=[{'type': 'text', 'text': ' HVAC Technical Support Resources', 'index': 0}] additional_kwargs={} response_metadata={} id='run--86d8f139-51d7-4b92-858b-dbc10a7f8fc2'
Stream metadata: {'thread_id': 'f92c93c9-9830-4473-a938-594d50409ba0', 'recursion_limit': 4, 'langgraph_step': 2, 'langgraph_node': 'final_answer', 'langgraph_triggers': ('branch:to:final_answer',), 'langgraph_path': ('__pregel_pull', 'final_answer'), 'langgraph_checkpoint_ns': 'final_answer:9ff545d7-9d6e-e89a-45df-05399c132c94', 'checkpoint_ns': 'final_answer:9ff545d7-9d6e-e89a-45df-05399c132c94', 'ls_provider': 'amazon_bedrock', 'ls_model_name': 'us.meta.llama4-maverick-17b-instruct-v1:0', 'ls_model_type': 'chat', 'ls_max_tokens': 8192}
Stream chunk: content=[{'type': 'text', 'text': '', 'index': 0}] additional_kwargs={} response_metadata={} id='run--86d8f139-51d7-4b92-858b-dbc10a7f8fc2'
Stream metadata: {'thread_id': 'f92c93c9-9830-4473-a938-594d50409ba0', 'recursion_limit': 4, 'langgraph_step': 2, 'langgraph_node': 'final_answer', 'langgraph_triggers': ('branch:to:final_answer',), 'langgraph_path': ('__pregel_pull', 'final_answer'), 'langgraph_checkpoint_ns': 'final_answer:9ff545d7-9d6e-e89a-45df-05399c132c94', 'checkpoint_ns': 'final_answer:9ff545d7-9d6e-e89a-45df-05399c132c94', 'ls_provider': 'amazon_bedrock', 'ls_model_name': 'us.meta.llama4-maverick-17b-instruct-v1:0', 'ls_model_type': 'chat', 'ls_max_tokens': 8192}
Stream chunk: content=[{'index': 0}] additional_kwargs={} response_metadata={} id='run--86d8f139-51d7-4b92-858b-dbc10a7f8fc2'
Stream metadata: {'thread_id': 'f92c93c9-9830-4473-a938-594d50409ba0', 'recursion_limit': 4, 'langgraph_step': 2, 'langgraph_node': 'final_answer', 'langgraph_triggers': ('branch:to:final_answer',), 'langgraph_path': ('__pregel_pull', 'final_answer'), 'langgraph_checkpoint_ns': 'final_answer:9ff545d7-9d6e-e89a-45df-05399c132c94', 'checkpoint_ns': 'final_answer:9ff545d7-9d6e-e89a-45df-05399c132c94', 'ls_provider': 'amazon_bedrock', 'ls_model_name': 'us.meta.llama4-maverick-17b-instruct-v1:0', 'ls_model_type': 'chat', 'ls_max_tokens': 8192}
Stream chunk: content=[] additional_kwargs={} response_metadata={'stopReason': 'end_turn'} id='run--86d8f139-51d7-4b92-858b-dbc10a7f8fc2'
Stream metadata: {'thread_id': 'f92c93c9-9830-4473-a938-594d50409ba0', 'recursion_limit': 4, 'langgraph_step': 2, 'langgraph_node': 'final_answer', 'langgraph_triggers': ('branch:to:final_answer',), 'langgraph_path': ('__pregel_pull', 'final_answer'), 'langgraph_checkpoint_ns': 'final_answer:9ff545d7-9d6e-e89a-45df-05399c132c94', 'checkpoint_ns': 'final_answer:9ff545d7-9d6e-e89a-45df-05399c132c94', 'ls_provider': 'amazon_bedrock', 'ls_model_name': 'us.meta.llama4-maverick-17b-instruct-v1:0', 'ls_model_type': 'chat', 'ls_max_tokens': 8192}
Stream chunk: content=[] additional_kwargs={} response_metadata={'metrics': {'latencyMs': 1047}, 'model_name': 'us.meta.llama4-maverick-17b-instruct-v1:0', 'ResponseMetadata': {'RequestId': '4de582bd-9e16-4a7b-9cca-e61d59a98b10', 'HTTPStatusCode': 200, 'HTTPHeaders': {'date': 'Tue, 16 Sep 2025 12:45:19 GMT', 'content-type': 'application/vnd.amazon.eventstream', 'transfer-encoding': 'chunked', 'connection': 'keep-alive', 'x-amzn-requestid': '4de582bd-9e16-4a7b-9cca-e61d59a98b10'}, 'RetryAttempts': 0}} id='run--86d8f139-51d7-4b92-858b-dbc10a7f8fc2' usage_metadata={'input_tokens': 1001, 'output_tokens': 46, 'total_tokens': 1047, 'input_token_details': {'cache_creation': 0, 'cache_read': 0}}
Stream metadata: {'thread_id': 'f92c93c9-9830-4473-a938-594d50409ba0', 'recursion_limit': 4, 'langgraph_step': 2, 'langgraph_node': 'final_answer', 'langgraph_triggers': ('branch:to:final_answer',), 'langgraph_path': ('__pregel_pull', 'final_answer'), 'langgraph_checkpoint_ns': 'final_answer:9ff545d7-9d6e-e89a-45df-05399c132c94', 'checkpoint_ns': 'final_answer:9ff545d7-9d6e-e89a-45df-05399c132c94', 'ls_provider': 'amazon_bedrock', 'ls_model_name': 'us.meta.llama4-maverick-17b-instruct-v1:0', 'ls_model_type': 'chat', 'ls_max_tokens': 8192}
Stream chunk: content=[{'type': 'text', 'text': "Hello Gandalf! Welcome to Carrier HVAC technical support. I'm here to help with any questions or issues you have regarding your Carrier equipment. What can I assist you with today?\n\n# References\n1. Carrier HVAC Technical Support Resources", 'index': 0}] additional_kwargs={} response_metadata={} id='4699525b-4551-413c-991f-8a82fe7fc95c'
Stream metadata: {'thread_id': 'f92c93c9-9830-4473-a938-594d50409ba0', 'recursion_limit': 4, 'langgraph_step': 2, 'langgraph_node': 'final_answer', 'langgraph_triggers': ('branch:to:final_answer',), 'langgraph_path': ('__pregel_pull', 'final_answer'), 'langgraph_checkpoint_ns': 'final_answer:9ff545d7-9d6e-e89a-45df-05399c132c94'}

Description

When streaming using stream mode of messages I get token-by-token messages and full message at the end. In the past versions I was only having token-by-token messages. The full message at the end adds redundancy.

System Info

System Information

OS: Linux
OS Version: #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025
Python Version: 3.12.11 (main, Sep 2 2025, 14:20:58) [Clang 20.1.4 ]

Package Information

langchain_core: 0.3.75
langchain: 0.3.27
langchain_community: 0.3.21
langsmith: 0.3.45
langchain_aws: 0.2.31
langchain_mcp_adapters: 0.1.9
langchain_mongodb: 0.7.0
langchain_openai: 0.3.32
langchain_text_splitters: 0.3.11
langgraph_sdk: 0.2.6

Optional packages not installed

langserve

Other Dependencies

aiohttp<4.0.0,>=3.8.3: Installed. No version info available.
async-timeout<5.0.0,>=4.0.0;: Installed. No version info available.
beautifulsoup4: Installed. No version info available.
bedrock-agentcore: Installed. No version info available.
boto3: 1.39.11
dataclasses-json<0.7,>=0.5.7: Installed. No version info available.
httpx: 0.27.2
httpx-sse<1.0.0,>=0.4.0: Installed. No version info available.
httpx>=0.25.2: Installed. No version info available.
jsonpatch<2.0,>=1.33: Installed. No version info available.
langchain-anthropic;: Installed. No version info available.
langchain-aws;: Installed. No version info available.
langchain-azure-ai;: Installed. No version info available.
langchain-cohere;: Installed. No version info available.
langchain-community;: Installed. No version info available.
langchain-core<0.4,>=0.3.36: Installed. No version info available.
langchain-core<1.0.0,>=0.3.51: Installed. No version info available.
langchain-core<1.0.0,>=0.3.72: Installed. No version info available.
langchain-core<1.0.0,>=0.3.74: Installed. No version info available.
langchain-core<2.0.0,>=0.3.75: Installed. No version info available.
langchain-core>=0.3: Installed. No version info available.
langchain-deepseek;: Installed. No version info available.
langchain-fireworks;: Installed. No version info available.
langchain-google-genai;: Installed. No version info available.
langchain-google-vertexai;: Installed. No version info available.
langchain-groq;: Installed. No version info available.
langchain-huggingface;: Installed. No version info available.
langchain-mistralai;: Installed. No version info available.
langchain-ollama;: Installed. No version info available.
langchain-openai;: Installed. No version info available.
langchain-perplexity;: Installed. No version info available.
langchain-text-splitters<1.0.0,>=0.3.9: Installed. No version info available.
langchain-text-splitters>=0.3: Installed. No version info available.
langchain-together;: Installed. No version info available.
langchain-xai;: Installed. No version info available.
langchain<1.0.0,>=0.3.23: Installed. No version info available.
langchain>=0.3: Installed. No version info available.
langsmith-pyo3: Installed. No version info available.
langsmith<0.4,>=0.1.125: Installed. No version info available.
langsmith>=0.1.17: Installed. No version info available.
langsmith>=0.3.45: Installed. No version info available.
lark<2.0.0,>=1.1.9: Installed. No version info available.
mcp>=1.9.2: Installed. No version info available.
numpy: 1.26.4
numpy<3,>=1.26.2: Installed. No version info available.
numpy>=1.26: Installed. No version info available.
openai-agents: Installed. No version info available.
openai<2.0.0,>=1.99.9: Installed. No version info available.
opentelemetry-api: 1.36.0
opentelemetry-exporter-otlp-proto-http: 1.36.0
opentelemetry-sdk: 1.36.0
orjson: 3.11.3
orjson>=3.10.1: Installed. No version info available.
packaging: 24.2
packaging>=23.2: Installed. No version info available.
playwright: Installed. No version info available.
pydantic: 2.11.7
pydantic-settings<3.0.0,>=2.4.0: Installed. No version info available.
pydantic<3.0.0,>=2.7.4: Installed. No version info available.
pydantic>=2.7.4: Installed. No version info available.
pymongo>=4.6.1: Installed. No version info available.
pytest: 8.3.3
PyYAML>=5.3: Installed. No version info available.
requests: 2.32.5
requests-toolbelt: 1.0.0
requests<3,>=2: Installed. No version info available.
rich: 13.9.4
SQLAlchemy<3,>=1.4: Installed. No version info available.
tenacity!=8.4.0,<10,>=8.1.0: Installed. No version info available.
tenacity!=8.4.0,<10.0.0,>=8.1.0: Installed. No version info available.
tiktoken<1,>=0.7: Installed. No version info available.
typing-extensions>=4.14.0: Installed. No version info available.
typing-extensions>=4.7: Installed. No version info available.
zstandard: 0.23.0

Metadata

Metadata

Labels

questionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions