Skip to content

fix(google-genai): preserve distinct streaming response parts - #276

Merged
nik13 merged 2 commits into
future-agi:devfrom
jabrailkhalil:fix/google-genai-stream-parts
Nov 9, 2026
Merged

nik13 merged 2 commits into
future-agi:devfrom
jabrailkhalil:fix/google-genai-stream-parts

Conversation

@jabrailkhalil

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #275. Keeps Gemini streaming response parts distinct instead of merging every part into position 0. A response containing weather(city="Paris") and time(zone="UTC") currently exports only the second call; adding text can hide both calls from the tool-call attributes.

Why?

Candidates have indexes; their parts do not. The existing list-append path in _ValuesAccumulator preserves the ordered parts without inventing an index or combining unrelated tool arguments, signatures and media. Candidate grouping and concatenated message-content attributes remain unchanged. Application-visible chunks are returned by identity.

output.value now contains the original part fragments in arrival order, including separate text fragments. README and changelog describe this trace-output change. This does not reconstruct Vertex partial_args into synthetic complete calls or change stream lifecycle handling.

How was it tested?

Linux CI and complete test/build artifacts check out 4d9f31ae00cf6a3d9e6b92041b0eb7be8f1c1b1f directly:

Python Google GenAI Result
3.10 1.8.0 (declared minimum) 18 passed, 2 skipped: SDK predates thought signatures
3.12 1.24.0 (package lock) 20 passed, 0 skipped
3.12 1.75.0 20 passed, 0 skipped
3.12 2.31.0 20 passed, 0 skipped
  • Sync/async cases cover parallel tools, repeated names, mixed text/tools, signatures, media, candidate separation, token/finish metadata, chunk identity, input immutability and empty/single-part controls.
  • Two integration cases use the real Google SDK and httpx.MockTransport, exercising request construction, SSE parsing, conversion and instrumentation. No live Gemini calls were made.
  • Every job restores the original production module while retaining these tests: 14 failures at the minimum SDK, 16 on the other versions, and no collection errors. The patched module passes afterward.
  • pip check, wheel build, Ruff correctness rules (E4,E7,E9,F), Black/isort on new tests and Mypy 1.18.2 pass in all four jobs. Local Windows/Python 3.12 checks pass too.

Checklist

  • Regression tests and offline SDK integration tests added.
  • README and changelog updated.
  • Branch off main; conventional commit; no secrets or new runtime dependencies.

Notes for reviewers

This is independent of #268 and #270, which change the Google ADK adapter. The production change here uses the existing accumulator's append behavior; no SDK patches or dependency changes are included.

Implementation and regression tests written with an OpenAI assistant under my supervision.

@jabrailkhalil
jabrailkhalil changed the base branch from main to dev November 1, 2026 22:51
@jabrailkhalil

jabrailkhalil commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor Author

I merged current dev in c28d7d9 and retargeted this PR per CONTRIBUTING. The four-SDK matrix passes: 18 passed/2 SDK-limited skips on 1.8.0; 20 passed on 1.24.0, 1.75.0 and 2.31.0. The baseline still fails 14/16 cases; wheel builds, type and style checks pass. No live Gemini calls were made.

@nik13
nik13 merged commit ad51611 into future-agi:dev Nov 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Google GenAI streaming traces overwrite parallel tool calls and merge unrelated parts

2 participants