Repository navigation
Python: [Bug]: Gemini streaming drops the model when a chunk has no model_version #9138
Copy link
Copy link
Labels
agentsUsage: [Issues, PRs], Target: Single agentUsage: [Issues, PRs], Target: Single agentpythonUsage: [Issues, PRs], Target: PythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflowUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
Description
Activity
- addedpythonUsage: [Issues, PRs], Target: PythonUsage: [Issues, PRs], Target: PythontriageUsage: [Issues], Target: All issues that still need to be triagedUsage: [Issues], Target: All issues that still need to be triaged
on Oct 7, 2026 - addedreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflowUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
on Oct 7, 2026 🤖 Automated triage reproduction notes (agent-authored — trust but verify)
Agent analysis
Repro:
python/packages/gemini/agent_framework_gemini/_chat_client.py::GeminiChatClient._process_chunkemitsmodel=Nonewhen a streamingGenerateContentResponse.model_versionis unset. Construct a client with modelgemini-2.5-flash, mock one model-less chunk throughget_response(..., stream=True), and assert the first update reports the configured model.- Failing test:
python/packages/gemini/tests/test_gemini_client.py::test_get_response_streaming_falls_back_to_configured_model - Files examined: python/packages/gemini/agent_framework_gemini/_chat_client.py, python/packages/gemini/tests/test_gemini_client.py, python/packages/core/agent_framework/_types.py, python/packages/core/agent_framework/observability.py, python/packages/gemini/pyproject.toml
- Tests run: python/packages/gemini/tests/test_gemini_client.py::test_get_response_streaming_falls_back_to_configured_model
- Reported version:
1.0.0b261002 - Current version:
1.0.0b261002
- Failing test:
- addedagentsUsage: [Issues, PRs], Target: Single agentUsage: [Issues, PRs], Target: Single agentand removedtriageUsage: [Issues], Target: All issues that still need to be triagedUsage: [Issues], Target: All issues that still need to be triaged
on Oct 7, 2026
Metadata
Metadata
Labels
agentsUsage: [Issues, PRs], Target: Single agentUsage: [Issues, PRs], Target: Single agentpythonUsage: [Issues, PRs], Target: PythonUsage: [Issues, PRs], Target: PythonreproducedUsage: [Issues], Target: all issues that can be reproduced by the triage workflowUsage: [Issues], Target: all issues that can be reproduced by the triage workflow
Type
Projects
- StatusShow more project fieldsNo status
Description
GeminiChatClient._process_chunkpasseschunk.model_versionstraight intoChatResponseUpdate.model, with no fallback._process_generate_response, 33 lines above in the same file, falls back toself.modelfor the same field:agent-framework/python/packages/gemini/agent_framework_gemini/_chat_client.py
Line 1058 in 279d97f
agent-framework/python/packages/gemini/agent_framework_gemini/_chat_client.py
Line 1091 in 279d97f
Both methods take the same type,
types.GenerateContentResponse(:1034-1036and:1066), andmodel_versionisOptional[str]there. The SDK documents per-chunk absence for the very next field of that class,prompt_feedback: "Sent only in the first stream chunk."What happens:
ChatResponse.modelis built only from the updates_types.py:2229-2230keeps the last non-Nonevalue, and the Gemini client has no catch-up afterwards so when no chunk carriesmodel_version, a streamed response ends up withmodel=None.What I expected: the configured model, which is what the non-streaming path reports for the same input.
Why it matters:
observability.py:3551-3552setsgen_ai.response.modelfrom that field.RESPONSE_MODELis part ofGEN_AI_METRIC_ATTRIBUTES(:3558), and_filter_metric_attributesdrops absent keys before_capture_responserecordstoken_usage_histogramandoperation_duration_histogram(:3604-3610). So on Gemini streams the token and duration histograms lose their per-model dimension, and_backfill_request_model(:1905) cannot recover the span name either.Steps to reproduce: drive
get_response(..., stream=True)over a single chunk whosemodel_versionis unset, then readupdates[0].model. No API key and no network are needed.Code Sample
Error Messages / Stack Traces
Package Versions
agent-framework-core: 1.20.0, agent-framework-gemini: 1.0.0b261002, google-genai: 2.27.0
Python Version
Python 3.11.4
Additional Context
MistralChatClient has the same asymmetry at _chat_client.py:800 / :830, but its SDK types CompletionChunk.model as required, so the gap is not reachable there. OllamaChatClient has no fallback on either path, so it is self-consistent. A PR for the Gemini case follows.