Skip to content

fix(llminternal): keep ModelVersion on the aggregated streaming response - #2070

Merged
wolo-lab merged 2 commits into
google:mainfrom
adityasingh2400:fix/stream-aggregator-model-version
Nov 6, 2026
Merged

wolo-lab merged 2 commits into
google:mainfrom
adityasingh2400:fix/stream-aggregator-model-version

Conversation

@adityasingh2400

Copy link
Copy Markdown
Contributor

Linked issue

Problem:
The response Close builds, which is what a streamed turn is stored as, doesn't copy ModelVersion, so every streamed model turn has an empty model version.

Solution:
Copy s.response.ModelVersion onto the response Close returns, as adk-python's aggregator does (src/google/adk/utils/streaming_utils.py:598-608).

Behavior change

Streamed model turns now carry the model version the API reported, as non-streamed turns already do. TestParallelFunctionCalls expected the empty value, so its expectations are updated to the versions in its existing recordings. Nothing was re-recorded.

Testing Plan

Unit Tests:

  • All unit tests pass locally.

Added TestCloseKeepsModelVersion. The recorded TestParallelFunctionCalls (3 models) now also checks the version.

With your source change reverted and your tests kept, which test fails?

--- FAIL: TestCloseKeepsModelVersion
    stream_aggregator_test.go:1186: final response ModelVersion = "", want "gemini-2.5-flash-001"
--- FAIL: TestParallelFunctionCalls

With the change, go test -race -count=1 ./internal/llminternal/... passes, go build ./... succeeds, and golangci-lint run reports 0 issues, with golangci-lint fmt --diff and go mod tidy -diff both empty.

Manual End-to-End (E2E) Tests:

N/A, covered by the unit test and the existing recordings.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Close built the aggregated response, the one a streamed turn is stored
as, without ModelVersion, so a streamed model turn lost the model version
that every chunk and a non-streamed response report. Copy it from the
last chunk, as adk-python's StreamingResponseAggregator.close does.
@indurireddy-TF

Copy link
Copy Markdown
Contributor

Hi @adityasingh2400 Thank you for the fix! I reviewed the changes and confirmed that they correctly preserve ModelVersion in the aggregated streaming response, aligning with the ADK-Python implementation. The regression test also covers the reported issue.
image
image

@wolo-lab Could you please take a look at this PR?

wolo-lab
wolo-lab previously approved these changes Nov 6, 2026

@wolo-lab wolo-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks

@wolo-lab
wolo-lab force-pushed the fix/stream-aggregator-model-version branch from 6c64062 to 2447fe0 Compare November 6, 2026 10:57
@wolo-lab
wolo-lab merged commit 8be9129 into google:main Nov 6, 2026
15 checks passed
wolo-lab added a commit that referenced this pull request Nov 16, 2026
…2071, #1249, #2070, #2190, #2301, #2310, #2308) (#2350)

* fix(llminternal): keep a streamed text chunk's thought signature on the merged part (#2071)

(cherry picked from commit 28201d6)

* test(llminternal): pin keep-last semantics for streaming usage metadata (#1249)

(cherry picked from commit afe6c86)

* fix(llminternal): keep ModelVersion on the aggregated streaming response (#2070)

(cherry picked from commit 8be9129)

* fix(llminternal): drop nil parts in the streaming aggregator (#2190)

(cherry picked from commit 46ff99b)

* fix(llminternal): skip live responses that carry nothing (#2301)

(cherry picked from commit 8cddb9d)

* fix(llminternal): keep responses that carry only grounding metadata (#2310)

(cherry picked from commit fc6de07)

* fix(llminternal): keep streamed function-call and event ids stable (#2308)

(cherry picked from commit 3188db9)
campoy added a commit to temporalio/ai-integrations that referenced this pull request Nov 17, 2026
#601)

## What was changed

ADK Go 2.8.0 came out today, and the nightly picks it up. Five tests
fail with it. Each one pins ADK behavior that 2.8.0 changes on purpose:

| Test | What ADK 2.8.0 changes |
|---|---|
| `TestAggregateResponsesGeminiTerminalAuthoritative` | Gemini's last
streamed response keeps `ModelVersion` (google/adk-go#2070) |
| `TestGeminiModelErrorIsNonRetryable` (blocked prompt, empty reply) | A
non-streamed reply with no candidates is a response with an `ErrorCode`,
not an `empty response` error (google/adk-go#2068) |
| `TestMCPToolConfirmationResumeHonorsCurrentToolFilter` | A call to an
unknown tool gets adk-python's message instead of "not found"
(google/adk-go#2316) |
| `TestRemoteSubAgentErrorNotRetried`, `TestRemoteSubAgentStreaming` | A
remote agent returns A2A errors from `Run` instead of turning them into
error events (google/adk-go#1740) |

The plugin code needs no change: it follows the new behavior, and
nothing is retried that wasn't before. For example, an A2A error still
fails after one Activity attempt; with 2.8.0 it now also fails the run,
as it does without Temporal.

go.mod keeps ADK 2.6.0, so CI tests 2.6.0 on pull requests and the
newest ADK every night. A new test helper, `ADKAtLeast`, reads the ADK
version from go.mod, and each of these tests expects the behavior of the
version it runs on. Why go.mod and not the build info? I tried the build
info first, but test binaries don't record dependency versions:
`debug.ReadBuildInfo` returns no deps at all. go.mod works because
`-mod=readonly` keeps it equal to the versions in the build. This makes
`golang.org/x/mod` a direct dependency, for tests only.

The blocked-prompt stub now has a `blockReasonMessage`, so on 2.8.0 the
test can check that the block reason reaches the run as an error event.

The README described the old behavior in two places: A2A errors and a
blocked Gemini prompt. Both now say what changes from 2.8.0.

## Why?

A red nightly blocks the `go/googleadk` release. Couldn't we raise the
floor to 2.8.0 and drop the old behavior instead? It would make the
tests simpler, but 2.8.0 came out today, and its release notes list a
breaking change of its own. That's too new to require from everyone at
GA.

## Checklist

1. Closes: no issue yet. The nightly hasn't run since ADK 2.8.0 came
out. A run with the newest dependencies on `main` shows the failures:
https://github.com/temporalio/ai-integrations/actions/runs/44004694511

2. How was this tested: in `go/googleadk`,
- with the committed go.mod (ADK 2.6.0), `make lint`, `make test` (with
and without `-race`) and `make build` pass.
- with the newest allowed dependencies (`make sync-latest`, ADK 2.8.0),
`make lint`, `make test TEST_ARGS=-race` and `make build` pass. Before
this change, `make test` failed in the five tests above.
- with ADK pinned back to 2.7.1 and everything else at its newest, the
five tests passed before this change, so 2.8.0 is the only cause.

3. Any docs updates needed? The README, updated here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

llminternal: streamed model turns are stored with an empty ModelVersion

3 participants