I’m using LangGraph with a setup where only the final AIMessage is shown to the end user. However, I noticed that the initial AIMessage, which includes natural language reasoning and tool calls (e.g., “Let me help you with each one…”), is not included in the final AI response returned by the graph.
Reproduction Steps:
- User asks a multi-part question.
- LangGraph LLM node (e.g., Claude or GPT) generates an initial
AIMessagewith:- greeting or partial answers
- a list of tool calls
- Tools are invoked and tool outputs are added as
ToolMessages. - The final
AIMessageis generated using the tool results. - Only this final AIMessage is returned to the user.
- The helpful context from the first
AIMessageis lost (e.g., intro, breakdown of queries, intent reasoning).
Expected Behavior:
I expect LangGraph to either:
- Automatically include the first AIMessage content in the final message shown to the user, or
- Provide an option or flag to merge all relevant AI text messages into one cohesive output.
Example:
Here’s a simplified illustration:
[
{
"type": "ai",
"content": "Hi, Hello How are you? Sure, let me break that down...",
"tool_calls": [...]
},
{
"type": "tool",
"name": "tool1",
"content": {...}
},
{
"type": "ai",
"content": "Here's your full response..."
}
]
But only the final AI message "Here's your full response..." is visible to the user. The Hello how are you is getting missed.
Suggestion:
It would be helpful to:
- Add a configuration flag (e.g.,
merge_ai_messages=True) - Or suggest an official pattern for users who want to manually concatenate all relevant AI text content before showing the final response