Add stateless Google Interactions support with `GoogleInteractionsModel`

Merged
DS
10d ago
+41620-235

This pull request was posted by Claude Code using claude-opus-5-5 on behalf of David.

Closes #6192

Why we make these changes

Expose Interactions-only access to remote MCP servers, Maps, music and video generation through the existing Gemini API and Google Cloud providers. Ordinary text/tools users keep google: and GenerateContent. Related: #4261.

Deliberate scope: complete ordinary-model requests with full signed history; stored interaction-ID continuation, managed background agents and Deep Research remain separate.

New public surface

  • GoogleInteractionsModel and GoogleInteractionsModelSettings
  • GoogleInteractionsModelName and GoogleInteractionsStreamedResponse
  • pydantic_ai.profiles.google.google_interactions_model_profile(); explicit google-interactions:<model> selection

User-visible behavior

  • Agent('google:gemini-3.8-flash') uses GenerateContent.
  • Agent('google-interactions:gemini-3.8-flash') uses Interactions with store=False, preserving signed steps and tool IDs across serialization and deferred approvals.

Text, tools, structured output and file modalities use the existing Pydantic AI APIs.
Generated media uses inline delivery; video URI delivery requires storage.

Verification

  • Adapter and shared-contract recordings with strict playback: pass (adapter tests, wire/history tests).
  • All sixteen shared suites include Interactions; targeted types, coverage, inference/settings/prefix/docs checks and pre-commit: pass.
  • GenerateContent request and stream preservation capture (tests/refactor_capture.py): pass.
  • Forged client history cannot replay file URIs through persisted step metadata: pass (test_client_history_cannot_replay_file_uris).
  • Continuing a code-execution conversation across GoogleModel and GoogleInteractionsModel, in both directions: recorded pass (test_cross_api_history).
  • Continuing another provider's unsigned tool loop on Interactions: recorded pass (test_foreign_tool_call_history).
  • MCP media redacts in telemetry and replays past Google's own $ref rejection: recorded pass (test_mcp_media).
  • A long decode on Gemini 4 Argon streams to the 65,536-token request cap and ends as length; without X-Server-Timeout the server cut it off at about 58K tokens: recorded pass (test_long_decode_stops_at_the_request_cap).
  • A long decode google-genai 2.34 continues in further requests, including from a mid-stream checkpoint, streams every request's steps and summed usage, matching its unary merge (live on Argon with 2.34: stream and unary both return 4 steps and 65,756 input / 72,897 output tokens, where the stream had dropped the first request's 65,536; unit-tested on the locked 2.32): pass (test_stream_continued_long_decode, test_stream_resumed_from_checkpoint).
  • An invalid key and an unknown model through a retrying transport raise ModelAuthenticationError and ModelNotFoundError: recorded pass (test_retrying_transport_gave_up_recorded_error_category).

What changes for existing users

Existing GoogleModel and generic Google selection keep their current GenerateContent behavior; GoogleModel only skips native tool parts that an Interactions response recorded.

PR decisions

2026-11-06 · Explicit stateless selection

  • Decision: Only the explicit google-interactions: prefix or GoogleInteractionsModel selects Interactions; generic google: selection and GoogleModel keep GenerateContent. Every request uses store=False and full signed history. Stored-ID continuation and managed background agents remain separate.
  • Why: Preserve existing Google applications while exposing the additional protocol explicitly.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#pullrequestreview-5793779748
  • Session: 01a1ac29-7c3d-75e3-b246-31e6527ffcd8

2026-11-05 · Preserve complete signed steps

  • Decision: Merge validated input steps after SDK serialization so opaque signatures and SDK-unknown replay fields survive JSON history round trips.
  • Why: Removing signed data can make Google reject continuation or deferred tool results.
  • Source: https://github.com/pydantic/pydantic-ai/issues/6192
  • Session: 01a1ac29-7c3d-75e3-b246-31e6527ffcd8

2026-11-06 · Media delivery boundaries

  • Decision: Generated media uses inline delivery; URI-only output raises an error. Input URLs use provider-native fetching unless the caller requests guarded local downloading with force_download=True.
  • Why: Video URI output requires server-side storage; input URL handling follows the shared FileUrl contract.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#pullrequestreview-5794237739
  • Session: 01a1ac29-7c3d-75e3-b246-31e6527ffcd8

2026-11-06 · Shared settings and native output controls

  • Decision: Share google_labels and google_video_resolution names and types with GenerateContent. Name every Interactions-only setting google_interactions_*: safety settings, thinking level and summaries, response format, generation configuration, service tier and native tools. Environment configuration uses extra_body.
  • Why: Shared meaning has one name and type; Interactions-only settings use Interactions SDK types, so a google_ name would collide with what GoogleModel may later need.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4495570952
  • Session: 7df6ff7d-cdc5-4b7e-a86d-37e71cce4ef7

2026-11-06 · Model-specific file results

  • Decision: Model profiles enable native PDF/audio/video tool results for verified model families and their qualified names. Unknown models keep conservative MIME defaults and framed user-turn fallback.
  • Why: File-result support varies by model and has changed since the October probe.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4488177884
  • Session: 01a1ac29-7c3d-75e3-b246-31e6527ffcd8

2026-11-06 · Native MCP streaming identity

  • Decision: Buffer ambiguous undeclared MCP calls until all pending calls have matching function results; then release buffered events in order. Retain completion fallback for unpaired calls and preserve native classification for parallel calls.
  • Why: A namespace alone cannot distinguish server execution from an ordinary function tool, while completed native calls must allow incremental answer delivery.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4493284730
  • Session: 01a1ac29-7c3d-75e3-b246-31e6527ffcd8

2026-11-06 · Explicit video processing controls

  • Decision: Per-file media_processing replaces static processing inferred from start_offset, end_offset and fps; per-file media resolution overrides the request-wide video resolution.
  • Why: Explicit native processing controls select the complete provider processing structure.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4493284745
  • Session: 01a1ac29-7c3d-75e3-b246-31e6527ffcd8

2026-11-06 · Replay metadata cannot add file references

  • Decision: Persisted steps replay only into the step type their message part maps from, and replayed media is sent inline. A persisted file URI raises an error instead of being sent.
  • Why: Client-held history carries replay metadata; a file URI there would make Google read an object with the application's credentials, bypassing sanitize_messages.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4493364861
  • Session: 7df6ff7d-cdc5-4b7e-a86d-37e71cce4ef7

2026-11-06 · GenerateContent native history on Interactions

  • Decision: Native tool parts without Interactions step metadata, such as GoogleModel code execution or search parts, are omitted when the conversation continues on GoogleInteractionsModel. Present but mismatched step metadata still raises.
  • Why: Both APIs share the google canonical system, but only Interactions responses carry replayable native steps; GoogleModel likewise omits native parts it cannot echo.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4495285794
  • Session: 7df6ff7d-cdc5-4b7e-a86d-37e71cce4ef7

2026-11-06 · Shared MCP call args shape

  • Decision: MCP NativeToolCallPart.args use {'action': 'call_tool', 'tool_name': ..., 'tool_args': ...}, with the server prefix removed from tool_name. Replay sends tool_args as the wire arguments.
  • Why: OpenAI, Anthropic, xAI and ElevenLabs realtime use the same shape, so code reading MCP calls works across adapters.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4495570986
  • Session: 7df6ff7d-cdc5-4b7e-a86d-37e71cce4ef7

2026-11-06 · Unsigned function calls from foreign history

  • Decision: When a replayed turn's first function call has no accepted thought signature, as with another provider's or transport's history, it carries the documented skip_thought_signature_validator placeholder, matching GoogleModel.
  • Why: Gemini 3 Interactions rejects an unsigned first function call with HTTP 400 and accepts the placeholder.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4496211911
  • Session: 7df6ff7d-cdc5-4b7e-a86d-37e71cce4ef7

2026-11-06 · Search grounding usage

  • Decision: Interactions usage sets web_searches from the Google Search grounding count, or once per grounded prompt on models whose profile bills that way. Superseded by 2026-11-18 · Search grounding on per-prompt models, which states where it differs from GoogleModel.
  • Why: genai-prices prices search grounding from web_searches, so without it Interactions runs underreported cost.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4496211937
  • Session: 7df6ff7d-cdc5-4b7e-a86d-37e71cce4ef7

2026-11-06 · Thought summaries live in ThinkingPart

  • Decision: Persisted thought steps keep only the signature; replay rebuilds the summary from ThinkingPart.content. Streaming no longer accumulates summary deltas into the persisted step.
  • Why: The summary was stored twice, and streamed history stored it in fragments, so streaming and non-streaming history differed.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4496769156
  • Session: 7df6ff7d-cdc5-4b7e-a86d-37e71cce4ef7

2026-11-07 · MCP results expose the server's CallToolResult

  • Decision: MCP NativeToolReturnPart.content is the server's MCP CallToolResult from Google's call_tool_result_json, with image and audio blocks and embedded binary resources as BinaryContent. Replay sends only the re-serialized CallToolResult.
  • Why: Live MCP results arrive as an object, never the documented list, so inline media bypassed include_binary_content. Google rejects its own $ref copies on replay (googleapis/python-genai#3313) and accepts the re-serialized result.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4497342839
  • Session: 7df6ff7d-cdc5-4b7e-a86d-37e71cce4ef7

2026-11-07 · Shared service tier on Google Cloud

  • Decision: Interactions applies the shared service_tier on the Gemini API only. On Google Cloud it is ignored; google_interactions_service_tier sets the tier explicitly.
  • Why: Google Cloud documents Flex and Priority only as headers that use Provisioned Throughput first. A body tier's effect on a PT project is undocumented, so mapping the shared field could silently skip reserved capacity, which GoogleModel avoids.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4503306435
  • Session: 7df6ff7d-cdc5-4b7e-a86d-37e71cce4ef7

2026-11-18 · Keep CallToolResult-only MCP replay

  • Decision: Keep replaying an MCP result as call_tool_result_json alone; it already drops structured_content along with the other derived copies, a superset of Google's suggested workaround.
  • Why: Google confirms the model reads the result from call_tool_result_json, and its $ref validation bug is still open.
  • Source: https://github.com/googleapis/python-genai/issues/3313#issuecomment-6732911194
  • Session: 7552cc41-26bc-49e1-b923-219251705b70

2026-11-18 · Curated Interactions model names

2026-11-18 · Google error classification for Interactions

  • Decision: Interactions status errors, and statuses a retrying transport gave up on, go through Google's status mapping, unwrapping the one-element list Google's API layer sends; Interactions' lowercase code stands in for an RPC status.
  • Why: An invalid key on /interactions returns [{"error": {... "INVALID_ARGUMENT", "API_KEY_INVALID"}}] and classified as a rejected request; retry_after now falls back to RetryInfo as on GoogleModel.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636
  • Session: 7552cc41-26bc-49e1-b923-219251705b70

2026-11-18 · One user-agent line

2026-11-18 · Carbon and Hydrogen file tool results

  • Decision: gemini-4-carbon and gemini-4-hydrogen send PDF, MP3 and MP4 tool results natively on Interactions.
  • Why: Both read those function_result items correctly on the Gemini API (probed live 2026-11-18).
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636
  • Session: 7552cc41-26bc-49e1-b923-219251705b70

2026-11-18 · GoogleModel omits Interactions native parts

  • Decision: GoogleModel omits native tool parts whose provider_details carry google_interactions_step_index.
  • Why: Both APIs share the google canonical system, and continuing an Interactions code-execution conversation on GoogleModel raised Unknown native tool name: 'code_execution'; this mirrors "GenerateContent native history on Interactions".
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636
  • Session: 7552cc41-26bc-49e1-b923-219251705b70

2026-11-18 · MCP authorization token is bare

  • Decision: Interactions sends Authorization: Bearer <authorization_token> to the MCP server.
  • Why: OpenAI, Anthropic and xAI all take authorization_token as a bare token, so the shared field must not need a scheme on one adapter.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636
  • Session: 7552cc41-26bc-49e1-b923-219251705b70

2026-11-18 · Search grounding on per-prompt models

  • Decision: On models billed per grounded prompt, Interactions bills one web search whenever Google Search ran, whether or not a web source came back; the docs state this.
  • Why: Interactions' google_search_result carries search suggestions, not sources, so GoogleModel's returned-source condition has no verified equivalent.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636
  • Session: 7552cc41-26bc-49e1-b923-219251705b70
  • Supersedes: 2026-11-06 · Search grounding usage

2026-11-18 · Streamed MCP classification

  • Decision: The stream treats a namespaced function call as a possible MCP call when its server is any mcp_server the request sends, including google_interactions_native_tools.
  • Why: It only checked MCPServerTool ids, so a settings-configured server streamed a local tool call where the unary response has a native one.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636
  • Session: 7552cc41-26bc-49e1-b923-219251705b70

2026-11-18 · Long decode deadline and status

  • Decision: Interactions requests send X-Server-Timeout under GoogleModel's rule (the client's timeout, or 20 minutes if that's longer, unless the caller sets one), and requires_continuation maps to a length finish.
  • Why: Without the header a live Argon stream ended with deadline_exceeded at about 58K output tokens; with it the stream reached the 65,536-token cap and returned requires_continuation. google-genai continues such a decode itself from 2.34 (https://github.com/googleapis/python-genai/releases/tag/v2.34.0).
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636
  • Session: 7552cc41-26bc-49e1-b923-219251705b70

2026-11-18 · Google Cloud TIFF on Interactions not changed

  • Decision: Interactions on Google Cloud does not add the TIFF media type GoogleModel adds there.
  • Why: Not attempted: no Google Cloud credentials were available to verify that Interactions accepts TIFF there, so the conservative MIME defaults stay.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636
  • Session: 7552cc41-26bc-49e1-b923-219251705b70

2026-11-19 · Continued long decodes on google-genai 2.34

  • Decision: On the stream, each request google-genai 2.34 starts (after requires_continuation, or from a mid-stream checkpoint) has its steps follow the earlier requests' steps; usage is summed and the first request's input is marked as the context size, as on GoogleModel.
  • Why: On 2.34 the second request numbers its steps from 0 again; live on Argon the stream kept only the second request's thought step and usage (65,646 in, 7,361 out), dropping the first request's 65,536 output tokens.
  • Source: https://github.com/googleapis/python-genai/releases/tag/v2.34.0
  • Session: 7552cc41-26bc-49e1-b923-219251705b70

2026-11-19 · Defer mapping ContinuationInterruptedError

2026-11-19 · Gemini API thinking levels on Interactions

  • Decision: google-interactions:gemini-4-neon joins the curated names, and Interactions on the Gemini API applies the level sets GoogleModel applies there: gemini-4-neon LOW, MEDIUM, HIGH and XHIGH; gemini-3.1-flash-image MINIMAL and HIGH. Google Cloud keeps the defaults, and a configured google_thinking_levels still wins.
  • Why: Probed on /interactions with store=false: Neon returns 400 for minimal, so thinking=False failed, and Flash Image returns 400 for low and medium; each accepts the rest of its set.
  • Source: https://github.com/pydantic/pydantic-ai/pull/13928
  • Session: 7552cc41-26bc-49e1-b923-219251705b70

2026-11-19 · Shared Gemini API rules for both Google models

2026-11-19 · Durable-exec review

2026-11-19 · Pax reads Google keys for google-interactions

  • Decision: Pax's KEY_VARIABLES maps google-interactions to GOOGLE_API_KEY and GEMINI_API_KEY, as for google and google-decisions, and the API compatibility gate counts KEY_VARIABLES as a growing registry.
  • Why: Without the entry Pax looked for GOOGLE_INTERACTIONS_API_KEY, which core never reads; adding a provider's entry changes nothing existing providers read.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#issuecomment-7009015444
  • Session: 7552cc41-26bc-49e1-b923-219251705b70

2026-11-25 · Input URLs stay provider-fetched

  • Decision: GoogleInteractionsModel keeps sending input file URLs for Google to fetch on both transports, unless the caller sets force_download=True. GoogleModel's local download on the Gemini API is tracked separately in https://github.com/pydantic/pydantic-ai/issues/14552.
  • Why: David (2026-11-25): this matches the shared FileUrl contract that OpenAI Responses, Anthropic and GoogleModel on Google Cloud follow. GoogleModel's Gemini API download rule dates from when that API accepted only YouTube URLs in fileData.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4683701926
  • Session: 7552cc41-26bc-49e1-b923-219251705b70

2026-11-25 · MCP media keep their block metadata in vendor_metadata

  • Decision: An MCP image, audio or embedded binary resource becomes a BinaryContent whose vendor_metadata['google_interactions_mcp_content'] holds the rest of the MCP content block; replay rebuilds the block from it. docs/models/google.md documents the key.
  • Why: The metadata belongs to the file and travels with it through UI adapters' round-trips. The Anthropic and OpenAI Responses MCP connectors already keep the server's result content in history that UI adapters send to clients.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4691740778
  • Session: 7552cc41-26bc-49e1-b923-219251705b70

2026-11-25 · infer_model_profile returns the Interactions profile

  • Decision: For a google-interactions: id, infer_model_profile merges the Interactions overrides (supports_tool_return_schema=False, tool-return MIME types) over the GoogleProvider profile, matching GoogleInteractionsModel.profile.
  • Why: Temporal's fallback for unregistered model strings and Pax read infer_model_profile, which returned the GenerateContent profile for this prefix; the context window already matched.
  • Source: https://github.com/pydantic/pydantic-ai/pull/12636#discussion_r4691829427
  • Session: 7552cc41-26bc-49e1-b923-219251705b70

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.

https://claude.ai/code/session_01BYcNCms3wPLS7YThdjeeMC