langflow icon indicating copy to clipboard operation
langflow copied to clipboard

Calling 2 tools with Google Generative AI Components returns 400

Open Baptiste-ms opened this issue 1 year ago • 12 comments

Bug Description

Hi, I found the following behaviour when chatting with the Google Generative AI component (GGAI), ie Gemini: With a simple flow, an agent and a tool, asking it to use the tool twice creates a 400 error code which traces to langchain_google_genai.chat_models.ChatGoogleGenerativeAIError: Invalid argument provided to Gemini: 400 * GenerateContentRequest.contents[14].parts[0].function_response.name: Name cannot be empty., recreation is quite easy.

Reproduction

Steps to reproduce this behaviour :

  1. Create a new Simple Agent flow
  2. Use the GGAI component and link it to 'custom' language model. (dont forget to choose a model, here I use 2.0-flash but the behaviour is the same with 1.5 pro etc.)
  3. Keep the calculator as a too and make sure inputs/outputs are ok
  4. Asking : "Can you compute what 24+9 and 1920/1.28" results in the error.
  5. Testing with another model provider (here I used Mistral) yields the right answer "The result of 24+9 is 33 and the result of 1920/1.28 is 1500. ".

Expected behavior

The error messages is as follows :

An error occured in the Agent Component, stopping your flow. See below for more details.
Error details:
ChatGoogleGenerativeAIError
**Details: Invalid argument provided to Gemini: 400 * GenerateContentRequest.contents[4].parts[0].function_response.name: Name cannot be empty. **

Who can help?

No response

Operating System

Ubuntu 24.04.2 LTS

Langflow Version

langflowai/langflow:1.4.2

Python Version

3.12

Screenshot

GGAI : Image

Mistral: Image

Langsmith trace: (EDIT) Image

Flow File

Simple Agent.json

Baptiste-ms avatar May 26 '25 08:05 Baptiste-ms

Based on your description and the available information, the 400 error (function_response.name: Name cannot be empty) when using the Google Generative AI (Gemini) component in Langflow appears to be related to how tool calls are handled when the agent is asked to use a tool multiple times in a single prompt.

Key Findings

  • The error message indicates that a required field (function_response.name) in the request to Gemini is empty, which is likely causing the 400 error from the API.
  • This issue is specific to the Google Generative AI component and does not occur with other providers like Mistral, suggesting a difference in how tool calls are structured or serialized for Gemini.
  • The GoogleGenerativeAIComponent in Langflow is responsible for generating text using Gemini and includes a tool_model_enabled input, which controls whether the tool model is used. Misconfiguration or a bug in how multiple tool calls are handled could result in missing or empty fields in the request payload, especially when the agent is asked to use a tool more than once in a single prompt [source].
  • There are no existing issues or discussions in the Langflow repository that specifically address this error or provide a direct fix.

What You Can Try

  • Check the tool_model_enabled Setting: Ensure that this is set appropriately for your use case. If you are using tools, this should typically be enabled. If it is disabled, the model may not handle tool calls correctly.
  • Review the Flow Configuration: Double-check that all required fields for the tool and agent are set and that the tool names are not empty or missing in your flow file.
  • Workaround: If possible, try splitting your prompt into separate requests (one tool call per prompt) as a temporary workaround until the underlying issue is resolved.
  • Recent Changes: The GoogleGenerativeAIComponent was recently updated (as of 2025-05-20), so if this issue started after an update, it may be related to recent changes in how tool calls are handled [source].

Limitations

  • Without access to the exact flow file and the ability to inspect the serialized request payload, it's not possible to pinpoint the exact misconfiguration or bug.
  • There is no official documentation or support thread that directly addresses this specific error with Gemini in Langflow.

If you continue to encounter this issue, consider isolating the problem by testing with different tool configurations or prompts, and monitor for updates to the Langflow or langchain_google_genai packages that may address this bug.

To continue talking to Dosu, mention @dosu-bot.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Bug Report | Other

dosubot[bot] avatar May 26 '25 08:05 dosubot[bot]

Adding comment for visibility. Same issue here and that bot's answer is useless.

CodyM0RGAN avatar May 29 '25 16:05 CodyM0RGAN

@dosu Could you please tag a member of langflow in this. Langflow relies on OpenAI style tool calling which is lenient with how tool responses are set. While Gemini is strict with it. The tool calling agent need to make sure that a unique function response name is sent to gemini.

raprajapati1208 avatar Jun 12 '25 10:06 raprajapati1208

got same problems

kholisrag avatar Jun 19 '25 10:06 kholisrag

Also experiencing this bug - any news?

nprice4 avatar Jul 29 '25 18:07 nprice4

Same problem here. Any news?

omerabr avatar Aug 09 '25 21:08 omerabr

It renders Gemini + tools, unusable. Anyone from the team can pick it up plz?

omerabr avatar Aug 18 '25 13:08 omerabr

does this still happen with 1.5.0post1?

namastex888 avatar Aug 22 '25 16:08 namastex888

does this still happen with 1.5.0post1?

Yes. Nonstop. Either with one or multiple tools.

omerabr avatar Aug 22 '25 16:08 omerabr

Hey all, PR open here: https://github.com/langflow-ai/langflow/pull/10214

erichare avatar Oct 10 '25 16:10 erichare

Same issue

hlog2e avatar Dec 11 '25 08:12 hlog2e

Hello, the issue is currently occurring in the latest version 1.7.2, but not in the main branch. Since it was fixed in main, I'm closing this issue.

If I missed anything, please comment here and I'll reopen. Thanks for the report.

AntonioABLima avatar Jan 21 '26 18:01 AntonioABLima