Skip to content

feat(py/plugins/google-genai): Deep Research, Antigravity, and Lyria interaction models - #5856

Closed
cabljac wants to merge 1 commit into
jh-interactions-2-transportfrom
jh-interactions-3-models
Closed

cabljac wants to merge 1 commit into
jh-interactions-2-transportfrom
jh-interactions-3-models

Conversation

@cabljac

@cabljac cabljac commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

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

  • LyriaModel is removed from genkit_google_genai.models.lyria; Lyria is now served by the Interactions-backed implementation (create_lyria_action). The package-level exports LyriaConfig and LyriaVersion are unchanged.

@gemini-code-assist gemini-code-assist Bot 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.

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.

Comment on lines +149 to +152
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)})

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.

high

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.

Suggested change
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)})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment on lines +140 to +141
if request.tools:
tools.extend(dict(to_interaction_tool(tool_def)) for tool_def in request.tools)

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.

medium

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.

Suggested change
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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

Comment on lines +118 to +119
# Default missing environment to remote; the API rejects unsupported values.
create_kwargs.setdefault('environment', DEFAULT_ENVIRONMENT)

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.

medium

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.

Suggested change
# 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())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

…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>
@cabljac
cabljac force-pushed the jh-interactions-3-models branch from 55e24fc to bbd82b6 Compare August 4, 2026 10:23

@hilariie hilariie 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.

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)})

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.

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

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.

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:

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.

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.

Comment on lines +122 to +134
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,
)

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.

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.

@hilariie

hilariie commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded by #6241, which landed Deep Research, Antigravity and Lyria on Interactions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants