[BUG] Error frequently occur when using Gemini within the Agent block #12121

Closed
opened 2026-02-21 19:05:53 -05:00 by yindo · 4 comments
Owner

Originally created by @Sanuki-073 on GitHub (Mar 25, 2025).

Originally assigned to: @crazywoola on GitHub.

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.1.3

Cloud or Self Hosted

Cloud

Steps to reproduce

Within the Agent block, when using Gemini, attempting to use multiple tools results in a 400 error.

✔️ Expected Behavior

Answers are generated based on the results obtained from the tool.

Actual Behavior

[models] Bad Request Error, 400 Please ensure that the number of function response parts should be equal to number of function call parts of the function call turn.
Image

Originally created by @Sanuki-073 on GitHub (Mar 25, 2025). Originally assigned to: @crazywoola on GitHub. ### Self Checks - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [x] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.1.3 ### Cloud or Self Hosted Cloud ### Steps to reproduce Within the Agent block, when using Gemini, attempting to use multiple tools results in a 400 error. ### ✔️ Expected Behavior Answers are generated based on the results obtained from the tool. ### ❌ Actual Behavior [models] Bad Request Error, 400 Please ensure that the number of function response parts should be equal to number of function call parts of the function call turn. <img width="731" alt="Image" src="https://github.com/user-attachments/assets/d72d3336-8482-4706-aeb1-21cfb0c26ba9" />
yindo added the 🐞 bug label 2026-02-21 19:05:53 -05:00
yindo closed this issue 2026-02-21 19:05:53 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Mar 25, 2025):

The error you're encountering, a "Bad Request Error, 400," suggests a mismatch between the number of function response parts and function call parts within the Agent block when using Gemini. This typically occurs when the system expects a certain number of responses based on the function calls made, but the actual responses do not match this expectation.

To address this issue, ensure that each function call within the Agent block is correctly paired with its corresponding response. This means that if you are calling multiple functions, like "current_time" and "simple_code," you need to ensure that each function call has a corresponding response part. Double-check the logic in your implementation to verify that all function calls are being handled correctly and that the responses are structured as expected.

If the problem persists, reviewing the implementation of the FunctionCallAgentRunner class might provide insights, as it manages the lifecycle of function calls and responses [1][2].

To continue talking to Dosu, mention @dosu.


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

@dosubot[bot] commented on GitHub (Mar 25, 2025): <!-- Answer --> The error you're encountering, a "Bad Request Error, 400," suggests a mismatch between the number of function response parts and function call parts within the Agent block when using Gemini. This typically occurs when the system expects a certain number of responses based on the function calls made, but the actual responses do not match this expectation. To address this issue, ensure that each function call within the Agent block is correctly paired with its corresponding response. This means that if you are calling multiple functions, like "current_time" and "simple_code," you need to ensure that each function call has a corresponding response part. Double-check the logic in your implementation to verify that all function calls are being handled correctly and that the responses are structured as expected. If the problem persists, reviewing the implementation of the `FunctionCallAgentRunner` class might provide insights, as it manages the lifecycle of function calls and responses <sup>[[1]](https://github.com/langgenius/dify-docs/blob/main/en/guides/workflow/node/agent.md)</sup><sup>[[2]](https://github.com/langgenius/dify/blob/main/api/core/agent/fc_agent_runner.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/c6bc7642-afaf-4652-a679-1a721df3377a?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/c6bc7642-afaf-4652-a679-1a721df3377a?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/c6bc7642-afaf-4652-a679-1a721df3377a?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/c6bc7642-afaf-4652-a679-1a721df3377a?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/c6bc7642-afaf-4652-a679-1a721df3377a?feedback_type=hallucination) | [Bug Report](https://app.dosu.dev/response-feedback/c6bc7642-afaf-4652-a679-1a721df3377a?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/c6bc7642-afaf-4652-a679-1a721df3377a?feedback_type=other)</sup>
Author
Owner

@crazywoola commented on GitHub (Mar 25, 2025):

What's your plugin version?

@crazywoola commented on GitHub (Mar 25, 2025): What's your plugin version?
Author
Owner

@Sanuki-073 commented on GitHub (Mar 25, 2025):

@crazywoola
gemini plugin version is 0.0.8.

Image
@Sanuki-073 commented on GitHub (Mar 25, 2025): @crazywoola gemini plugin version is 0.0.8. <img width="1493" alt="Image" src="https://github.com/user-attachments/assets/5be82d1d-e300-4126-b5bf-b21a61edc26c" />
Author
Owner

@backrunner commented on GitHub (Mar 27, 2025):

Same here, using Dify v1.1.3 with the Gemini plugin v0.0.8.
The model is Gemini 2.0 Pro Experimental, using ReAct strategy in Agent node, got the 400 error

@backrunner commented on GitHub (Mar 27, 2025): Same here, using Dify v1.1.3 with the Gemini plugin v0.0.8. The model is Gemini 2.0 Pro Experimental, using ReAct strategy in Agent node, got the 400 error
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#12121