Using Gemini as a backend now results in a HTTP 400 Error when using tools
To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.
Describe the bug
When attempting to use tools we get a 400 response from Gemini:
LLM response status: 400 body: [{
"error": {
"code": 400,
"message": "Please ensure that function call turn comes immediately after a user turn or after a function response turn.",
"status": "INVALID_ARGUMENT"
}
}
]
To Reproduce Steps to reproduce the behavior:
- Start `eca' in a project
- C-c RET - select google/gemini-3-flash-preview
- Run query which triggers tool use, e.g. /init
- Witness 400 error
Doctor Running /doctor did confuse the model but it did spit out the following after some thought.
LLM response status: 400 body: [{
"error": {
"code": 400,
"message": "Function call is missing a thought_signature in functionCall parts. This is required for tools to work correctly, and missing
thought_signature may lead to degraded model performance. Additional data, function call default_api:eca__read_file , position 6. Please refer to
https://ai.google.dev/gemini-api/docs/thought-signatures for more details.",
"status": "INVALID_ARGUMENT"
}
}
]
@zikajk do you think that could be related with your recent changes?
@ericdallo I am not sure, but I will try to fix it soon. It looks like it is related to parallel tool calls.
I can confirm the gemini-2.5-pro works but the gemini-3-pro-preview fails with the same warning. Obviously given the inference costs involved I would rather stick to the gemini-3-flash-preview as that seems to give the most bang for buck.
Spoke too soon - gemini-2.5-pro got through the /init step but failed later on. Maybe the slower response meant its less likely to race?
Running 'emacs -batch -l ert -l ed...' ❌ 0.10 s
Tool: shell_command
Server: eca
Arguments:
command: "emacs -batch -l ert -l edit-server-test.el -f ert-run-tests-batch-and-exit"
Output: Exit code 255
Stderr:
Loading /etc/emacs/site-start.d/00debian.el (source)...
Loading /etc/emacs/site-start.d/50asymptote.el (source)...
Loading /etc/emacs/site-start.d/50autoconf.el (source)...
Loading /etc/emacs/site-start.d/50devhelp.el (source)...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading /etc/emacs/site-start.d/50global.el (source)...
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...
Error while loading 50latex-cjk-common: Symbol’s value as variable is void: flavor
Loading /etc/emacs/site-start.d/50latex-cjk-thai.el (source)...
Error while loading 50latex-cjk-thai: Symbol’s value as variable is void: flavor
Loading /etc/emacs/site-start.d/50latexmk.el (source)...
Loading /etc/emacs/site-start.d/50texlive-lang-english.el (source)...
Cannot open load file: No such file or directory, edit-server
Stdout:
Error: file-missing ("Cannot open load file" "No such file or directory" "edit-server")
require(edit-server)
load-with-code-conversion("/home/alex/mysrc/edit-with-emacs.git/edit-server-test.el" "/home/alex/mysrc/edit-with-emacs.git/edit-server-test.el" nil t)
command-line-1(("-l" "ert" "-l" "edit-server-test.el" "-f" "ert-run-tests-batch-and-exit"))
command-line()
normal-top-level()
Thought 0.00 s
The user wants me to fix the test command.
The previous command failed because `edit-server.el` was not in Emacs' `load-path`.
I need to add the current directory to the `load-path` so that Emacs can find `edit-server.el`.
The command should be `emacs -batch -L . -l ert -l edit-server-test.el -f ert-run-tests-batch-and-exit`.
The `-L .` part adds the current directory to the `load-path`.The test failed because `edit-server.el` isn't in Emacs' `load-path`. I'll add the current directory to the `load-path` and rerun the test.
Running 'emacs -batch -L . -l ert ...' ❌ 0.09 s
Tool: shell_command
Server: eca
Arguments:
command: "emacs -batch -L . -l ert -l edit-server-test.el -f ert-run-tests-batch-and-exit"
Output: Exit code 255
Stderr:
Loading /etc/emacs/site-start.d/00debian.el (source)...
Loading /etc/emacs/site-start.d/50asymptote.el (source)...
Loading /etc/emacs/site-start.d/50autoconf.el (source)...
Loading /etc/emacs/site-start.d/50devhelp.el (source)...
Loading /etc/emacs/site-start.d/50dictionaries-common.el (source)...
Loading /etc/emacs/site-start.d/50global.el (source)...
Loading /etc/emacs/site-start.d/50latex-cjk-common.el (source)...
Error while loading 50latex-cjk-common: Symbol’s value as variable is void: flavor
Loading /etc/emacs/site-start.d/50latex-cjk-thai.el (source)...
Error while loading 50latex-cjk-thai: Symbol’s value as variable is void: flavor
Loading /etc/emacs/site-start.d/50latexmk.el (source)...
Loading /etc/emacs/site-start.d/50texlive-lang-english.el (source)...
Cannot open load file: No such file or directory, edit-server
Stdout:
Error: file-missing ("Cannot open load file" "No such file or directory" "edit-server")
require(edit-server)
load-with-code-conversion("/home/alex/mysrc/edit-with-emacs.git/edit-server-test.el" "/home/alex/mysrc/edit-with-emacs.git/edit-server-test.el" nil t)
command-line-1(("-L" "." "-l" "ert" "-l" "edit-server-test.el" "-f" "ert-run-tests-batch-and-exit"))
command-line()
normal-top-level()
LLM response status: 400 body: [{
"error": {
"code": 400,
"message": "Please ensure that function call turn comes immediately after a user turn or after a function response turn.",
"status": "INVALID_ARGUMENT"
}
}
]
Fixed by https://github.com/editor-code-assistant/eca/pull/262/, @stsquad can you try latest release please?
@stsquad It should be fixed now. From time to time, Gemini breaks the
@zikajk looks good now - I have run through and /init and done some long chain prompts and it seems stable. Thanks!