gemini-3.5-flash with generate_content_stream + automatic function calling stops after tool execution and returns empty final text
I maintainer di solito rispondono entro 1 giorno
@Venkaiahbabuneelam ci sta già lavorando.
Dal 9/6/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Summary
When using gemini-3.5-flash with generate_content_stream and automatic function calling enabled, the model executes a tool successfully but then ends the stream with:
finish_reason = STOP- final candidate content containing only
{"text": ""} - no visible text
- no
automatic_function_calling_history
The same workflow works with gemini-2.5-flash, and the same logical flow works if we do not rely on AFC streaming.
Date observed
June 9, 2026
Environment
- Python SDK:
google-genai 2.8.0 - Model:
gemini-3.5-flash - Method:
client.models.generate_content_stream(...) - Automatic function calling enabled
- Python 3.11
- Also reproduced previously with
google-genai 1.50.0
Scenario
We have a tool-based structured-data agent. The expected flow is:
- model calls a discovery tool
- tool returns a valid candidate
- model either continues tool usage or emits final text
In this case, step 2 succeeds, but the model immediately ends the stream with an empty final text candidate.
Minimal observed behavior
User question:
What is the birth rate for SampleTown in 2023?
Tool call executed successfully:
find_metric_candidates(query="birth rate")
Tool result:
{
"query": "birth rate",
"result": [
{
"id": 101,
"name": "Crude birth rate",
"dataset": "public_metrics_table",
"metric_type": 1,
"geo_levels": "City, Region, Country",
"match_source": "name_contains"
}
],
"row_count": 1
}
But the stream ends with:
{
"content": {
"parts": [
{
"text": ""
}
],
"role": "model"
},
"finish_reason": "STOP",
"index": 0
}
No visible text is produced.
Expected behavior
After a successful tool call, the model should either:
- continue with additional tool calls, or
- emit a final visible text response
It should not end with STOP and an empty text-only candidate.
Actual behavior
- tool executes successfully
- stream returns HTTP 200
- final chunk has
finish_reason=STOP - final candidate has
text="" - no
automatic_function_calling_history - no visible output
Sanitized diagnostic logs
HTTP Request: POST .../models/gemini-3.5-flash:streamGenerateContent?alt=sse "HTTP/1.1 200 OK"
[Tool] find_metric_candidates called
[Tool] query: birth rate
[Tool] returned 1 row
[DIAG] chunk=1 text_len=0 has_history=False finish_reason=FinishReason.STOP parts=['empty_text']
[DIAG RAW] candidate={'content': {'parts': [{'text': ''}], 'role': 'model'}, 'finish_reason': 'STOP', 'index': 0}
Comparison
gemini-2.5-flashworks correctly in the same agent/tool flowgemini-3.5-flashfails in AFC streaming mode- similar behavior was observed across multiple Gemini 3 family models in this workflow
Workarounds tried
- prompt changes
- thinking configuration changes
- SDK upgrade from
1.50.0to2.8.0
The issue still reproduces in AFC streaming mode.
Question
- Is this a known limitation or bug in
gemini-3.5-flashwithgenerate_content_stream+ automatic function calling? - If this is expected behavior, what is the recommended pattern for Gemini 3.5 in this scenario?
- Lingua principale
- Python
- Stelle
- 4k
- Fork
- 1k
- Merge medio
- 1g 18h
- PR unite (30g)
- 52
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di googleapis/python-genai
-
[Bug]: Unsubscripted typing.List and typing.Dict crash convert_if_exist_pydantic_model in AFCForse già presa @chauvuusvn l’ha presa 1 giorno fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
googleapis/python-genai#3044 ·
I maintainer di solito rispondono entro 1 giorno
-
Name collision in google.genai.interactions: triggers.Interaction shadows response model Interaction in static type checkersForse già presa @Venkaiahbabuneelam l’ha presa 6 giorni fa. Apertapriority: p2 type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
googleapis/python-genai#3013 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 78/100
googleapis/python-genai#3031 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Live `AsyncSession.send_tool_response` fails with `TypeError` when `FunctionResponse.parts` carries inline bytesForse già presa @Venkaiahbabuneelam l’ha presa 4 giorni fa. Apertapriority: p2 type: bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
googleapis/python-genai#3022 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[Live API] gemini-3.8-live-extended-thinking: announces tool call then says "I apologize, but a system error occurred." with no functionCall frame - 61% of tool runs (n=64)Forse già presa @Venkaiahbabuneelam l’ha presa 6 giorni fa. Apertapriority: p2 status:awaiting user response type: bug
googleapis/python-genai#3015 · 1 commento · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di googleapis/python-genai
Issue simili
-
Zero-token evaluations are treated as missing cost in selectionForse già presa @sylvesterkaczmarek l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
google-research/rrsi#6 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
aws-samples/sample-aws-genai-db-modernizer#294 ·
I maintainer di solito rispondono entro 1 giorno
-
feedback simulation workshop
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
githubnext/gh-aw-workshop#4174 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
WingedGuardian/GENesis-AGI#2852 ·
I maintainer di solito rispondono entro 1 giorno
-
camlight produces degenerate target camera and light framesForse già presa @kavyabhand l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
google-deepmind/mujoco_warp#1743 ·
I maintainer di solito rispondono entro 1 giorno