Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for Google AI Interactions models, including the new Antigravity and Deep Research models, and refactors the existing Lyria model to use the Interactions API. It also centralizes model metadata in a new registry and adds comprehensive unit tests. The review feedback highlights a few important issues: ensuring that Pydantic models are dumped using aliases (by_alias=True) so that camelCase keys are preserved for the API, avoiding redundant dictionary wrapping, and copying the mutable module-level DEFAULT_ENVIRONMENT dictionary to prevent unintended side effects from shared state mutation.
| if config.file_search is not None: | ||
| tools.append({'type': 'file_search', **config.file_search.model_dump(exclude_none=True)}) | ||
| for mcp_server in config.mcp_servers or []: | ||
| tools.append({'type': 'mcp_server', **mcp_server.model_dump(exclude_none=True)}) |
There was a problem hiding this comment.
The FileSearchConfig and McpServerConfig models define an alias_generator to produce camelCase keys (e.g., fileSearchStoreNames, allowedTools) for the wire format. However, calling model_dump(exclude_none=True) without by_alias=True serializes these configurations with snake_case keys (e.g., file_search_store_names, allowed_tools). This will cause the Google AI Interactions API to reject or ignore these settings. Passing by_alias=True ensures they are correctly serialized to camelCase.
| if config.file_search is not None: | |
| tools.append({'type': 'file_search', **config.file_search.model_dump(exclude_none=True)}) | |
| for mcp_server in config.mcp_servers or []: | |
| tools.append({'type': 'mcp_server', **mcp_server.model_dump(exclude_none=True)}) | |
| if config.file_search is not None: | |
| tools.append({'type': 'file_search', **config.file_search.model_dump(by_alias=True, exclude_none=True)}) | |
| for mcp_server in config.mcp_servers or []: | |
| tools.append({'type': 'mcp_server', **mcp_server.model_dump(by_alias=True, exclude_none=True)}) |
There was a problem hiding this comment.
The suggestion would break these requests rather than fix them. This body goes over a raw HTTP client verbatim, and the whole create payload is snake_case (agent_config, previous_interaction_id, user_input, mime_type in the content blocks), so camelCasing only these two nested blocks would produce a mixed-casing body. The SDK's own FileSearchDict/McpServerDict types also take snake_case keys. The alias_generator on these models handles the input direction (camelCased request config), not serialization.
| if request.tools: | ||
| tools.extend(dict(to_interaction_tool(tool_def)) for tool_def in request.tools) |
There was a problem hiding this comment.
to_interaction_tool(tool_def) returns a FunctionParam which is a TypedDict (inheriting from dict at runtime). Wrapping it in dict(...) is redundant and creates an unnecessary shallow copy of the dictionary. You can safely pass the returned dictionary directly to tools.extend.
| if request.tools: | |
| tools.extend(dict(to_interaction_tool(tool_def)) for tool_def in request.tools) | |
| if request.tools: | |
| tools.extend(to_interaction_tool(tool_def) for tool_def in request.tools) |
There was a problem hiding this comment.
Correct that the copy is a no-op (to_interaction_tool builds a fresh dict per call). No functional difference; will drop it in the next tidy commit on this slice.
| # Default missing environment to remote; the API rejects unsupported values. | ||
| create_kwargs.setdefault('environment', DEFAULT_ENVIRONMENT) |
There was a problem hiding this comment.
DEFAULT_ENVIRONMENT is a mutable module-level dictionary. Using it directly in setdefault means that if any downstream code or library mutates the environment dictionary inside create_kwargs, it will inadvertently mutate the shared DEFAULT_ENVIRONMENT constant, affecting all subsequent requests. It is safer to use .copy() to avoid shared mutable state.
| # Default missing environment to remote; the API rejects unsupported values. | |
| create_kwargs.setdefault('environment', DEFAULT_ENVIRONMENT) | |
| # Default missing environment to remote; the API rejects unsupported values. | |
| create_kwargs.setdefault('environment', DEFAULT_ENVIRONMENT.copy()) |
There was a problem hiding this comment.
Nothing mutates the environment dict downstream today (the body goes straight to JSON serialization), but the shared-reference risk is real and the fix is cheap. Will take this.
01b294e to
65d52d6
Compare
65d52d6 to
a4b2a47
Compare
f7fbd08 to
55e24fc
Compare
…interaction models Model layer extracted from #5806: Deep Research background model with cancel support, Antigravity and Lyria foreground models backed by the Interactions transport, and a shared registry of known models with capability metadata. Rewrites lyria.py from the legacy Vertex-only LyriaModel to the Interactions-backed implementation. Plugin wiring into GoogleAI init/resolve/list_actions lands in the next slice of the stack, together with its integration tests. Co-authored-by: Jeff Huang <huangjeff@google.com>
55e24fc to
bbd82b6
Compare
hilariie
left a comment
There was a problem hiding this comment.
The breaking changes section says LyriaConfig and LyriaVersion are unchanged, but both changed substantially. LyriaVersion swaps LYRIA_002 for LYRIA_3_CLIP and LYRIA_3_PRO, and LyriaConfig replaces all four of its fields (negative_prompt, seed, sample_count, location) with the Interactions client options. Only the exported names are the same.
Worth noting that neither was reachable through any plugin before this stack, so nothing functional regresses, but the release notes get built from this section.
| if config.file_search is not None: | ||
| tools.append({'type': 'file_search', **config.file_search.model_dump(exclude_none=True)}) | ||
| for mcp_server in config.mcp_servers or []: | ||
| tools.append({'type': 'mcp_server', **mcp_server.model_dump(exclude_none=True)}) |
There was a problem hiding this comment.
Could we add tests for the file_search and mcp_servers branches here, plus response_format_from_request? None of the three are exercised in interactions_models_test.py.
These are the only places where the wire keys depend on model_dump being called without by_alias. Both config models set alias_generator=to_camel, so the correct file_search_store_names and allowed_tools only happen by omission. If someone adds by_alias=True later, it silently sends camelCase and no test fails.
| # Milliseconds — applied to the HTTP call, not the create body. | ||
| timeout: float | None = None | ||
| custom_headers: dict[str, str] | None = None | ||
| thinking_summaries: Literal['auto', 'none'] | None = None |
There was a problem hiding this comment.
The JS config accepts thinkingSummaries: 'AUTO' | 'NONE' and lowercases before building the request body. This accepts only 'auto' | 'none', and the same split applies to visualization and to response_modalities across all three models.
This means that a config copied from the JS samples can raise a ValidationError in Python.
| 'response_modalities': modalities, | ||
| **passthrough, | ||
| } | ||
| if system_instruction: |
There was a problem hiding this comment.
This path has no JS counterpart. JS Lyria passes messages straight to toInteractionSteps with no system handling, so sending system_instruction and skipping the empty input guard is new behavior here. If this divergence from JS is intentional, there should be a test for the system-only case to pin the intent, since it is the one path that can reach the API with empty input.
| def deep_research_model(version: str) -> ModelRef: | ||
| """Return a ModelRef for a Deep Research version (namespaced or bare).""" | ||
| clean = extract_version(version) | ||
| info = KNOWN_DEEP_RESEARCH_MODELS.get(clean) or DEEP_RESEARCH_INFO | ||
| # Prefer a version-specific label over the shared catalog default. | ||
| if info.label is None or info.label == DEEP_RESEARCH_INFO.label: | ||
| info = ModelInfo(label=f'Google AI - {clean}', supports=info.supports) | ||
| return model_ref( | ||
| name=clean, | ||
| namespace='googleai', | ||
| info=info, | ||
| config_schema=DeepResearchConfig, | ||
| ) |
There was a problem hiding this comment.
This reproduces the labeling that deep_research_model_info already does. Every entry in KNOWN_DEEP_RESEARCH_MODELS has either label=None or label == DEEP_RESEARCH_INFO.label, so the condition on line 127 is always true and the result is the same ModelInfo the registry helper returns.
Could this just call deep_research_model_info(version)? It keeps the labeling rule in the one file the registry docstring points people at.
|
Closing as superseded by #6241, which landed Deep Research, Antigravity and Lyria on Interactions. |
Third slice of the #5806 split: Deep Research background model with cancel support, Antigravity and Lyria foreground models on the Interactions transport, and a registry of known models with capability metadata. Rewrites lyria.py from the legacy Vertex-only LyriaModel. Model-level tests included here; plugin wiring and its integration tests land in the next slice.
Part of the stack splitting #5806; recombined it reproduces that PR byte-for-byte. Co-authored with @huangjeff5.
Breaking changes
LyriaModelis removed fromgenkit_google_genai.models.lyria; Lyria is now served by the Interactions-backed implementation (create_lyria_action). The package-level exportsLyriaConfigandLyriaVersionare unchanged.