Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix(FlowiseChatGoogleGenerativeAI): Prevent "parts must not be empty" API error in Seq Agents #4285

Closed
wants to merge 2 commits into from

Conversation

toi500
Copy link
Contributor

@toi500 toi500 commented Apr 11, 2025

Problem:
The ChatGoogleGenerativeAI node can fail with Google API errors (requires alternate messages or parts must not be empty) when used in sequential flows like loops or agents. This happens because Flowise appends a final user message which can violate API rules (consecutive user roles or empty parts if "Human Prompt" is empty).

Example Error:
image

Solution:
Modified the convertBaseMessagesToContent helper function to fix the message list before the API call:

  1. Merges Consecutive Roles: A post-processing step now merges consecutive messages if they have the same role and simple text content. This fixes role alternation issues and implicitly removes potentially empty placeholder messages.
  2. Adds Safeguard: A final check adds a minimal user message (...) if the list ends in model 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:
image

@toi500 toi500 closed this Apr 12, 2025
@toi500 toi500 reopened this Apr 12, 2025
@toi500 toi500 closed this Apr 12, 2025
@toi500
Copy link
Contributor Author

toi500 commented Apr 13, 2025

Merged here #4292

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant