agent strategy function call error with gemini flash model #314

Closed
opened 2026-02-16 10:18:58 -05:00 by yindo · 2 comments
Owner

Originally created by @muzhi1991 on GitHub (May 27, 2025).

Originally assigned to: @laipz8200 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

latest

Cloud or Self Hosted

Cloud

Steps to reproduce

Configuration: An agent node, use the built-in Agent policy, select functioncall, and select the 2.5 flash 0520 version of gemini (I have no limit to test other models). The tool choose time/current time
Test: Preview Chat Enter: Current time.

✔️ Expected Behavior

Normal call tool

Actual Behavior

output error:
Run failed: Failed to transform agent message: PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [google] Error: PluginInvokeError: {"args":{"description":"function_call_id received is not a string"},"error_type":"InvokeError","message":"function_call_id received is not a string"}"}

Originally created by @muzhi1991 on GitHub (May 27, 2025). Originally assigned to: @laipz8200 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 latest ### Cloud or Self Hosted Cloud ### Steps to reproduce Configuration: An agent node, use the built-in Agent policy, select functioncall, and select the 2.5 flash 0520 version of gemini (I have no limit to test other models). The tool choose time/current time Test: Preview Chat Enter: Current time. ### ✔️ Expected Behavior Normal call tool ### ❌ Actual Behavior output error: Run failed: Failed to transform agent message: PluginInvokeError: {"args":{},"error_type":"Exception","message":"read llm model failed: request failed: [google] Error: PluginInvokeError: {"args":{"description":"function_call_id received is not a string"},"error_type":"InvokeError","message":"function_call_id received is not a string"}"}
yindo closed this issue 2026-02-16 10:18:58 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (May 27, 2025):

Hi @muzhi1991! I'm Dosu and I’m helping the dify team.

The error function_call_id received is not a string during an agent strategy function call with the Gemini Flash model appears to be caused by a type mismatch—where the system expects function_call_id to be a string, but it receives a different type. This typically happens during the parsing and handling of tool calls in the agent workflow.

Here are some key findings that may help resolve or diagnose the issue:

  • The agent function call logic in Dify expects tool call information (including tool_call_id) to be properly formatted and typed. If the LLM (in this case, Gemini 2.5 Flash 0520) returns a tool call with an ID that is not a string, this error will occur. The relevant logic is in the FunctionCallAgentRunner class, which parses tool call arguments and IDs from the LLM response. If the arguments or IDs are not as expected, it can trigger this error. See the implementation details here.

  • The Gemini 1.5 Flash model is configured to support tool-calling features, so in principle, it should be compatible with function calling workflows. However, if the model's output format changes or is inconsistent, it could cause type mismatches like this one. See model capabilities here.

  • The current_time tool itself is implemented to accept parameters and return the current time, and is not likely the direct cause of the type error unless the tool call arguments are malformed upstream. See the tool implementation here.

  • There is a known issue where some models do not support function calling properly, leading to instability with tools like current_time. If the Gemini model's function calling output is not fully compatible with Dify's expectations, this could be the root cause. A similar issue was reported with another model, where switching to a model with robust function calling support resolved the problem. See the related issue here.

  • A previous, similar issue with agent nodes and function calling was resolved by a pull request. Reviewing the changes in that PR may provide further insight: Issue langgenius/dify#15118.

Potential solutions and next steps:

  • Double-check that the Gemini model you are using is fully compatible with function calling and that its output matches Dify's expected schema (especially for function_call_id).
  • If possible, test with another model known to work with function calling to see if the issue persists.
  • If you have custom tools or modifications, ensure that all tool call IDs are strings before they are returned or processed.
  • Review the recent changes in the Dify codebase and the PR that fixed a similar issue for any relevant updates.

If you need more detailed troubleshooting, providing a sample of the raw LLM response that triggers the error could help pinpoint the exact mismatch.

To reply, just mention my name @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (May 27, 2025): <!-- Greeting --> Hi @muzhi1991! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the dify team. <!-- Answer --> The error `function_call_id received is not a string` during an agent strategy function call with the Gemini Flash model appears to be caused by a type mismatch—where the system expects `function_call_id` to be a string, but it receives a different type. This typically happens during the parsing and handling of tool calls in the agent workflow. Here are some key findings that may help resolve or diagnose the issue: - The agent function call logic in Dify expects tool call information (including `tool_call_id`) to be properly formatted and typed. If the LLM (in this case, Gemini 2.5 Flash 0520) returns a tool call with an ID that is not a string, this error will occur. The relevant logic is in the `FunctionCallAgentRunner` class, which parses tool call arguments and IDs from the LLM response. If the arguments or IDs are not as expected, it can trigger this error. See the implementation details [here](https://github.com/langgenius/dify/blob/main/api/core/agent/fc_agent_runner.py). - The Gemini 1.5 Flash model is configured to support tool-calling features, so in principle, it should be compatible with function calling workflows. However, if the model's output format changes or is inconsistent, it could cause type mismatches like this one. See model capabilities [here](https://github.com/langgenius/dify/blob/main/api/core/model_runtime/model_providers/google/llm/gemini-1.5-flash-8b-exp-0924.yaml). - The `current_time` tool itself is implemented to accept parameters and return the current time, and is not likely the direct cause of the type error unless the tool call arguments are malformed upstream. See the tool implementation [here](https://github.com/langgenius/dify/blob/main/api/core/tools/builtin_tool/providers/time/tools/current_time.py). - There is a known issue where some models do not support function calling properly, leading to instability with tools like `current_time`. If the Gemini model's function calling output is not fully compatible with Dify's expectations, this could be the root cause. A similar issue was reported with another model, where switching to a model with robust function calling support resolved the problem. See the related issue [here](https://github.com/langgenius/dify/issues/16908). - A previous, similar issue with agent nodes and function calling was resolved by a pull request. Reviewing the changes in that PR may provide further insight: [Issue langgenius/dify#15118](https://github.com/langgenius/dify/issues/15118). **Potential solutions and next steps:** - Double-check that the Gemini model you are using is fully compatible with function calling and that its output matches Dify's expected schema (especially for `function_call_id`). - If possible, test with another model known to work with function calling to see if the issue persists. - If you have custom tools or modifications, ensure that all tool call IDs are strings before they are returned or processed. - Review the recent changes in the Dify codebase and the PR that fixed a similar issue for any relevant updates. If you need more detailed troubleshooting, providing a sample of the raw LLM response that triggers the error could help pinpoint the exact mismatch. <!-- Dosu Comment Footer --> *To reply, just mention my name [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/12792267-5d19-4b03-b06a-1461bed0418e?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/12792267-5d19-4b03-b06a-1461bed0418e?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/12792267-5d19-4b03-b06a-1461bed0418e?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/12792267-5d19-4b03-b06a-1461bed0418e?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/12792267-5d19-4b03-b06a-1461bed0418e?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/12792267-5d19-4b03-b06a-1461bed0418e?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/12792267-5d19-4b03-b06a-1461bed0418e?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/20283)
Author
Owner

@laipz8200 commented on GitHub (May 28, 2025):

Image

Gemini 1.5 Pro is the same.

@laipz8200 commented on GitHub (May 28, 2025): <img width="1119" alt="Image" src="https://github.com/user-attachments/assets/9f41eb11-2b8d-497d-a306-543436608616" /> Gemini 1.5 Pro is the same.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify-official-plugins#314