Repository navigation
Description
TanStack AI version
@tanstack/ai v0.10.1;
Framework/Library version
@tanstack/ai-gemini v0.8.5
Describe the bug and the steps to reproduce it
I provided a simple tool and try to use it with gemini-3.1-flash-lite-preview, but it always fires a 400 error. The call works, it crashed after the response from my server.
⚠️ EDIT: It seems to work withgemini-2.5-flash, maybe it's on Google side 🤔. Still the duplicate function response seems odd.
I feel like it may be because there are two parts :
- one with text
- one with functionResponse
{
"parts": [
{
"text": "{\"id\":\"root\",\"name\":\"Root\",\"type\":\"folder\",\"children\":[{\"id\":\"dd2f5a5f\",\"name\":\"New page\",\"type\":\"component\"},{\"id\":\"cbadb546\",\"name\":\"New Store\",\"type\":\"store\"}]}"
},
{
"functionResponse": {
"id": "rmny7t6v",
"name": "getProjectFileTree",
"response": {
"content": "{\"id\":\"root\",\"name\":\"Root\",\"type\":\"folder\",\"children\":[{\"id\":\"dd2f5a5f\",\"name\":\"New page\",\"type\":\"component\"},{\"id\":\"cbadb546\",\"name\":\"New Store\",\"type\":\"store\"}]}"
}
}
}
],
"role": "user"
}I suspect it may be because of this: https://discuss.ai.google.dev/t/error-400-when-llm-response-contains-both-text-and-functioncall/70826
Also, having the response of the function call in both parts doesn't seem to be very efficient to me... I think the part with text shouldn't be here.
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
Here's the full payload
{
"contents": [
{
"parts": [
{
"text": "Check my project tree and suggest new names"
}
],
"role": "user"
},
{
"parts": [
{
"functionCall": {
"id": "rmny7t6v",
"args": {},
"name": "getProjectFileTree"
}
}
],
"role": "model"
},
{
"parts": [
{
"text": "{\"id\":\"root\",\"name\":\"Root\",\"type\":\"folder\",\"children\":[{\"id\":\"dd2f5a5f\",\"name\":\"New page\",\"type\":\"component\"},{\"id\":\"cbadb546\",\"name\":\"New Store\",\"type\":\"store\"}]}"
},
{
"functionResponse": {
"id": "rmny7t6v",
"name": "getProjectFileTree",
"response": {
"content": "{\"id\":\"root\",\"name\":\"Root\",\"type\":\"folder\",\"children\":[{\"id\":\"dd2f5a5f\",\"name\":\"New page\",\"type\":\"component\"},{\"id\":\"cbadb546\",\"name\":\"New Store\",\"type\":\"store\"}]}"
}
}
}
],
"role": "user"
}
],
"systemInstruction": {
"parts": [
{
"text": "You are **Sidekick**, an expert AI assistant for the **Luna Park** visual editor. [...]\r\n"
}
],
"role": "user"
},
"tools": [
{
"functionDeclarations": [
{
"name": "getProjectFileTree",
"description": "Get the project file tree",
"parameters": {
"type": "OBJECT",
"properties": {}
}
}
]
}
],
"generationConfig": {}
}Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
Maybe, I'll investigate and start debugging
Terms & Code of Conduct
- I agree to follow this project's Code of Conduct
- I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.
Activity
hugoattal commentedon Apr 9, 2026
Minimum reproduction :
Sends
{ "parts": [ { "text": "[\"trains\",\"rockets\"]" }, { "functionResponse": { "id": "6gimt3fv", "name": "getCoolStuff", "response": { "content": "[\"trains\",\"rockets\"]" } } } ] }hugoattal commentedon Apr 13, 2026
Proof that this is being sent to the LLM
fix(ai-gemini): remove redundant text part from functionResponse mess…
fix(ai-gemini): remove redundant text part from functionResponse mess…