Skip to content

test(google-genai): fix the Interactions mocks for google-genai 2.34 - #296

Merged
ralf0131 merged 2 commits into
alibaba:mainfrom
pylaterreur:fix-google-genai-2.34
Oct 31, 2026
Merged

ralf0131 merged 2 commits into
alibaba:mainfrom
pylaterreur:fix-google-genai-2.34

Conversation

@pylaterreur

Copy link
Copy Markdown
Contributor

Description

Since google-genai 2.34.0 (2026-10-29), the loongsuite-instrumentation-google-genai-latest jobs fail on Python 3.11 to 3.15. On 3.10 they pass, because 2.34.0 needs Python 3.11 and 3.10 still gets 2.33.0. test_instrumentation_does_not_break_core_functionality (sync and async) gets <MagicMock name='mock.model_copy().id'> instead of test-id. main and every pull request that runs the full matrix fail the same way.

google-genai 2.34.0 adds automatic continuation to interactions.create (googleapis/python-genai#3226). The public create merges the hops it sends, even a single one, into a copy made with model_copy(update=...), both for the interaction and for its usage. The tests return MagicMock interactions from the generated create, and MagicMock().model_copy() is a new mock without the configured fields.

Only the tests are affected. The instrumentation wraps the generated create and reads each hop's response, as before. With real objects over a mocked HTTP API:

  • a single-hop interaction gives the same object and the same span on 2.33.0 and 2.34.0;
  • an interaction continued over two hops gives one span per request.

This PR mocks the interaction and its usage as pydantic-like models whose model_copy keeps their fields.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

tox -c tox-loongsuite.ini -e py3{10,11,12,13,14,15}-test-loongsuite-instrumentation-google-genai-{latest,oldest} (tox-uv, GitHub CPython builds), online and offline (bwrap --unshare-net):

  • latest, Python 3.11 to 3.15: 226 passed, with google-genai 2.34.0 and with 2.33.0. Without this change, 2.34.0 fails the same 2 tests as CI.
  • latest, Python 3.10 (google-genai 2.33.0): 226 passed.
  • oldest (google-genai 1.32.0), Python 3.10 to 3.15: 182 passed.
  • tox -e precommit passes.

Does This PR Require a Core Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

🤖 Generated with Claude Code

https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN

🤖 Generated with Claude Code

https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN

google-genai 2.34.0 (2026-10-29) adds automatic continuation to
interactions.create. The public create now merges the hops it sends,
even a single one, into a copy of the interaction made with
model_copy(update=...), for the interaction and for its usage. The
tests return MagicMock interactions from the generated create, and
MagicMock().model_copy() is a new mock without the configured fields,
so test_instrumentation_does_not_break_core_functionality got a mock id.

The instrumentation is unaffected: it wraps the generated create and
reads each hop's response, as before. With real objects over a mocked
HTTP API, a single-hop interaction gives the same object and span on
2.33.0 and 2.34.0, and an interaction continued over two hops gives one
span per request.

Mock the interaction and its usage as pydantic-like models whose
model_copy keeps their fields.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN

Copilot AI 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.

🟢 Approval recommended

No active review issues were identified, with the changes focused on updating test fixtures and documenting compatibility with google-genai 2.34.0.

No open issues 🎉

What changed in this PR

Updates Google GenAI Interactions test fixtures for compatibility with google-genai 2.34.0, whose interactions.create implementation copies interaction and usage models via model_copy.

Changes:

  • Added field-preserving, pydantic-like MagicMock fixtures.
  • Updated interaction and usage mocks to preserve fields across copies.
  • Documented the compatibility fix in the changelog.
File Description
instrumentation-loongsuite/​loongsuite-instrumentation-google-genai/​tests/​interactions/​util.py Adds model-copy-aware mocks for interaction responses and usage data.
instrumentation-loongsuite/​loongsuite-instrumentation-google-genai/​CHANGELOG.md Records the google-genai 2.34 compatibility fix.

Review effort: Lite

alibaba#294 added extended_types to the API docs. Napoleon reads the first
line of an attribute docstring written as "Name: text" as "type:
description", so the "Streaming:" prefix of
InvokeAgentInvocation.monotonic_first_token_s became a py:class
reference to "Streaming". Nitpicky mode reports it and -W makes it an
error, so the docs job fails on every pull request since alibaba#294. Reword
the docstring.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN
@pylaterreur

Copy link
Copy Markdown
Contributor Author

Same as on #295: this PR now also contains #295's docstring fix (same content), so its CI can go green on its own. Merging either PR makes the other's duplicate commit empty.

🤖 Generated with Claude Code

https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN

@pylaterreur

Copy link
Copy Markdown
Contributor Author

@ralf0131 same as on #295: all checks pass now, and the approval was dismissed by my push of the other PR's commit (same content). Could you approve again?

🤖 Generated with Claude Code

https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN

@ralf0131
ralf0131 merged commit b526277 into alibaba:main Oct 31, 2026
278 checks 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.

5 participants