Repository navigation
test(google-genai): fix the Interactions mocks for google-genai 2.34 - #296
pylaterreur wants to merge 2 commits into
Conversation
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
There was a problem hiding this comment.
🟢 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
MagicMockfixtures. - 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
|
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 |
|
@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 |
Description
Since google-genai 2.34.0 (2026-10-29), the
loongsuite-instrumentation-google-genai-latestjobs 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 oftest-id.mainand 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 publiccreatemerges the hops it sends, even a single one, into a copy made withmodel_copy(update=...), both for the interaction and for its usage. The tests return MagicMock interactions from the generatedcreate, andMagicMock().model_copy()is a new mock without the configured fields.Only the tests are affected. The instrumentation wraps the generated
createand reads each hop's response, as before. With real objects over a mocked HTTP API:This PR mocks the interaction and its usage as pydantic-like models whose
model_copykeeps their fields.Type of change
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 precommitpasses.Does This PR Require a Core Repo Change?
Checklist:
🤖 Generated with Claude Code
https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN
🤖 Generated with Claude Code
https://claude.ai/code/session_01GwUvhmzgfkiZ6vo4uGyesN