You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Google GenAI streaming traces overwrite parallel tool calls and merge unrelated parts #275
traceai-google-genai 0.1.2, main at 54421a6 (the same accumulator is present on dev).
What happens
Gemini response parts are ordered and have no index. The streaming accumulator treats them as indexed entries, defaults every part to index 0, and merges unrelated parts together.
With two parallel calls (weather(city="Paris") and time(zone="UTC")), the trace retains only time. Two calls to the same function also collapse. If text arrives alongside the tool calls, the merged part contains both text and function_call, and the text branch of attribute extraction hides the tool calls entirely. Repeated media parts are overwritten too. The chunks returned to the application still contain the correct calls; the exported trace is wrong.
Offline reproduction
fromgoogle.genaiimporttypesfromtraceai_google_genai._streamimport_ResponseAccumulatoracc=_ResponseAccumulator()
acc.process_chunk(types.GenerateContentResponse(candidates=[
types.Candidate(index=0, content=types.Content(role="model", parts=[
types.Part(function_call=types.FunctionCall(name="weather", args={"city": "Paris"})),
types.Part(function_call=types.FunctionCall(name="time", args={"zone": "UTC"})),
]))
]))
print(acc._result()["candidates"][0]["content"]["parts"])
# Actual: [{'function_call': {'args': {'zone': 'UTC'}, 'name': 'time'}}]# Expected: two distinct parts, retaining both calls and their own arguments.
I reproduced this with GenAI 1.8.0, 1.24.0, 1.75.0 and 2.31.0, including the real SDK's sync/async SSE parsing through an in-memory HTTP transport. No provider key or network call is needed. I have a patch that appends parts in order while keeping candidate indexing and concatenated message-text attributes intact.
Implementation and regression tests written with an OpenAI assistant under my supervision.
Thanks for reporting the dropped stream parts and contributing #276. With the follow-up in #656, adjacent text fragments coalesce without overwriting distinct tool calls or multimedia parts. The Google GenAI 0.1.4 release explicitly includes these cases. Closing as fixed.
Activity
nik13 commentedon Nov 18, 2026
Thanks for reporting the dropped stream parts and contributing #276. With the follow-up in #656, adjacent text fragments coalesce without overwriting distinct tool calls or multimedia parts. The Google GenAI 0.1.4 release explicitly includes these cases. Closing as fixed.