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 with gemini-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
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.I feel like it may be because there are two parts :
{ "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