Fix(FlowiseChatGoogleGenerativeAI): Prevent "parts must not be empty" API error in Seq Agents #4285
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem:
The
ChatGoogleGenerativeAI
node can fail with Google API errors (requires alternate messages
orparts must not be empty
) when used in sequential flows like loops or agents. This happens because Flowise appends a finaluser
message which can violate API rules (consecutiveuser
roles or empty parts if "Human Prompt" is empty).Example Error:

Solution:
Modified the
convertBaseMessagesToContent
helper function to fix the message list before the API call:user
message (...
) if the list ends inmodel
after merging, ensuring API compliance.Result:
This makes the node significantly more robust for sequential agents and loops by handling common structural issues caused by Flowise's message handling.
Reproducible Flow:
gemini-seq-agent-bug Agents.json
Also tested successfully with multi-agent setups:
