Fixes tool results followed by user text causing Gemini API errors
LangChain fixes Gemini integration to stop merging tool results with subsequent user messages.
Patch Changes #11426 `2e865ea` Thanks @thushanth-bengre-langchain! - fix: keep image/audio/video content in ToolMessages as sibling Gemini parts instead of losing it inside functionResponse.response.result JSON, and stop double-stringifying non-string tool results (#10297, #10439) #11477 `9a0f244` Thanks @hntrl! - Fix `convertMessagesToGeminiContents` merging a `ToolMessage` (functionResponse) with a following `HumanMessage` (text) into one `user` content. Both map to the `user` role, and Vertex/Gemini rejects a single `user` content that mixes a `functionResponse` with text, so a tool result followed by a user message would fail with a 400.
Merging is now limited to runs of adjacent tool results (parallel tool calls), which the API requires to be grouped into one content; all other same-role contents stay separate. Also fixes the v1 standard-content path, where a single `ToolMessage` could emit a `user` content mixing its `functionResponse` part with text parts; tool turns now carry only their functionResponse part(s), mirroring the legacy path.
- github.comLangChain (JS) — google v0.2.4primary