Agentflow
Agentflow copied to clipboard
Gemini 400 INVALID_ARGUMENT on parallel tool calls — _convert_to_google_format doesn't group consecutive tool results
Gemini's contract: one model turn = one Content with all function_call parts → the following user turn must be a single Content whose parts are all the matching function_responses (same count, same order). The current converter breaks this whenever the agent issues parallel tool calls in a single turn.
Relevant files
agentflow/core/graph/agent_internal/google.py—_convert_to_google_format. Needs to group consecutiverole="tool"messages into oneContent(role="user", parts=[fr1, fr2, ...])(e.g. outerwhile i < n+ innerwhile messages[i].role == "tool"), and extract a_tool_response_part(msg)helper to keep the loop readable. The existingcall_id_to_namemap can be reused for the lookup.
Happy to send a PR.