INVALID_ARGUMENT resuming a saved chat (400 BadRequest)
What happened?
After /chat save, /quit, gemini, /chat load the conversation history is showing up but the response to all prompts is:
✕ [API Error: [{
"error": {
"code": 400,
"message": "Please ensure that the number of function response parts is equal to the number of function call parts of the function call turn.",
"errors": [
{
"message": "Please ensure that the number of function response parts is equal to the number of function call parts of the function call turn.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
]]
> What do we do with error messages like above?
✕ [API Error: [{
"error": {
"code": 400,
"message": "Please ensure that the number of function response parts is equal to the number of function call parts of the function call turn.",
"errors": [
{
"message": "Please ensure that the number of function response parts is equal to the number of function call parts of the function call turn.",
"domain": "global",
"reason": "badRequest"
}
],
"status": "INVALID_ARGUMENT"
}
}
]]
The settings.json file is pretty vanilla
{
"theme": "Dracula",
"selectedAuthType": "oauth-personal",
"preferredEditor": "cursor"
}
What did you expect to happen?
Resume my chat with the entire history in the context as if I never interrupted it.
Client information
$ gemini -v
0.1.3
Login information
No response
Anything else we need to know?
No response
same problem for me - looks like a bug
Im stuck at this exact point
Same, it's very annoying. My workaround was to open a new chat in cursor with gemini 2.5 pro, then do this:
- Ask it to look through this link to find where conversations are stored: https://github.com/google-gemini/gemini-cli/tree/main
- Ask it to find the conversation that crashed and copy the it into a non-hidden folder
- Start a new conversation in gemini-cli and @ the file so it can read the last conversation.
I can take a stab at this.
Initial Analysis
The Problem
When loading a saved chat that contained function calls and responses:
- The code was displaying function call/response items in the UI, even though they have no displayable text
- This created a mismatch in the chat history where the Gemini API expected function calls and responses to be properly paired
The Solution
Modified /packages/cli/src/ui/hooks/slashCommandProcessor.ts to:
- Continue adding all items to the chat history (to maintain API compatibility)
- Only display items that contain text content and aren't function calls/responses
- Add a check hasOnlyText to identify items that contain only text parts
- Skip displaying items with function calls or responses while keeping them in the history
Same issue here. Guess I won't be experimenting with your software this weekend.
same
same problem here
I am also getting same error
for me this happens when it wants to take two actions, but if I want to interrupt and stop it from executing them. To do that I have to hit escape twice. And when I do that every subsequent follow up via question or slash command has this number of function response mismatch problem.
I've gone back to Claude Code. Feels like it was released too early. Like Firebase Studio.
One alternative that has worked for me is:
- Manually copy the entire current conversation from the terminal and save it to a text file, for example: history.txt.
- When starting a new Gemini session, you can say something like:
“Please use the contents of the history.txt file as context to continue where we left off.”
This doesn't fix, but it allows you to continue your workflow.
I'm hitting this same issue now after successfully using GCLI yesterday. I'll try the history.txt hack
Same issue. For me, seems like it started happening after I setup the Supabase mcp. And I think it crashes during/ after mcp functions.
It completely disables the terminal, after some of these errors. And gets stuck. Keep getting the same error when you type anything & send, or try to continue.
Same issue here
Hello friends, we're trying to actively track down the cause for this issue. Would you all mind hopping over to https://github.com/google-gemini/gemini-cli/issues/3131#issuecomment-3032567269 and answering some of those questions to help me get to the bottom of this?
got this once.
@NTaylorMullen is this fixed via #3333?
same issue here - using 0.1.12
✕ [API Error: [{ "error": { "code": 400, "message": "Please ensure that the number of function response parts is equal to the number of function call parts of the function call turn.", "errors": [ { "message": "Please ensure that the number of function response parts is equal to the number of function call parts of the function call turn.", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT" } } ]]
Using 1 GEMINI.md file
✕ [API Error: [{ "error": { "code": 400, "message": "Please ensure that the number of function response parts is equal to the number of function call parts of the function call turn.", "errors": [ { "message": "Please ensure that the number of function response parts is equal to the number of function call parts of the function call turn.", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT" } } ]]
I have seen this twice including today
Hi mate! @NTaylorMullen Just wanted to ask you if there's any news of fixing this issue in the near future!
Thank you for building this amazing tool.
Best regards, Andrés