Skip to content

feat(py/google-genai): wire Antigravity tools, multi-turn continuation, and 09-2026 - #7004

Merged
huangjeff5 merged 1 commit into
mainfrom
feat/py-antigravity-builtin-tools
Nov 4, 2026
Merged

huangjeff5 merged 1 commit into
mainfrom
feat/py-antigravity-builtin-tools

Conversation

@huangjeff5

@huangjeff5 huangjeff5 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Wires Antigravity tool support and multi-turn continuation in Python (genkit-google-genai) to match JS:

  1. Client function calling (ai.generate(tools=...)): Forwards Genkit tools as {type: 'function', ...}, handles requires_action pauses in from_interaction_sync, and keeps already-resolved sandbox file calls (write_to_file, etc.) out of ToolRequest parts.
  2. Multi-turn continuation (previous_interaction_id + environment_id): Resumes from the last model turn's interactionId and environmentId metadata, slicing input to only newer messages so tool calls/results aren't replayed into input.
  3. Server tool passthrough (extra={'tools': [...]}): Unblocks extra['tools'] on AntigravityConfig (sent ahead of request.tools) and rejects extra={'tools': []} before any HTTP call.

Closes #6711
Closes #7043

# 1. Default (nothing passed) -> wire omits `tools` (search, url_context, code_execution all ON)
await ai.generate(
    model=GoogleAI.antigravity('antigravity-preview-09-2026'),
    prompt='Reconcile invoice subtotal $224.49 with 8.25% tax.',
)

# 2. Server tool allowlist only -> wire `tools` sends only these built-ins (sandbox bash OFF)
await ai.generate(
    model=GoogleAI.antigravity('antigravity-preview-09-2026'),
    prompt='Summarize the allergen policy at three Austin ramen shops.',
    config=AntigravityConfig(
        extra={'tools': [{'type': 'google_search'}, {'type': 'url_context'}]},
    ),
)
# => wire tools: [{"type": "google_search"}, {"type": "url_context"}]

# 3. Server tools + custom Genkit tool -> concatenated as [*extra_tools, *function_tools]
response = await ai.generate(
    model=GoogleAI.antigravity('antigravity-preview-09-2026'),
    prompt='Cross-check the allergen policy at three Austin ramen shops against our supplier list.',
    tools=[lookup_supplier_allergens],
    config=AntigravityConfig(
        extra={
            'tools': [
                {'type': 'google_search'},
                {'type': 'url_context'},
                {'type': 'mcp_server', 'name': 'pos', 'url': 'https://pos.example/mcp'},
            ]
        },
    ),
)
# => wire tools: [{"type": "google_search"},
#                 {"type": "url_context"},
#                 {"type": "mcp_server", "name": "pos", "url": "https://pos.example/mcp"},
#                 {"type": "function", "name": "lookup_supplier_allergens", ...}]

# 4. Multi-turn chat -> reuses previous_interaction_id + environment_id (pass tools/config again if still needed; tools are per-request)
turn1 = await ai.generate(
    model=GoogleAI.antigravity('antigravity-preview-09-2026'),
    prompt='Write reconciled totals to /tmp/report.csv.',
)
follow_up = await ai.generate(
    model=GoogleAI.antigravity('antigravity-preview-09-2026'),
    messages=[*turn1.messages, Message(role='user', content=[Part.from_text('Add a row for tip.')])],
)
# => follow_up reuses turn1's previous_interaction_id + environment_id (/tmp/report.csv stays on disk) and sends only the new message

# 5. Empty list raises before any HTTP call (`tools: []` on the wire turns all 3 defaults back ON)
await ai.generate(
    model=GoogleAI.antigravity('antigravity-preview-09-2026'),
    prompt='...',
    config=AntigravityConfig(extra={'tools': []}),
)
# => INVALID_ARGUMENT: googleai/antigravity-preview-09-2026: extra['tools'] cannot be empty ([]).

Main Changes

  • Client function calling & sandbox call filtering ([google-genai] Antigravity supports function calling now; py and js plugins still declare tools: false #6711): ANTIGRAVITY_INFO.supports.tools is now True. from_interaction_sync treats status='requires_action' as a deliberate pause rather than an error, converting unmatched function_call steps into ToolRequest parts while stashing paired sandbox calls (write_to_file + function_result) in custom['serverFunctionCall'] so Genkit's tool loop does not try to run server-side sandbox tools locally.
  • Multi-turn previous_interaction_id + environment_id continuation ([py/google-genai] Continue Antigravity multi-turn conversations via previous_interaction_id and environment_id #7043): When config.previous_interaction_id is unset, select_antigravity_continuation walks request.messages backward to the last model turn with metadata['interactionId'], sends only messages after that turn, and reuses metadata['environmentId'] unless the caller pinned a custom environment. Explicit previous_interaction_id also slices history after the last model turn.
  • Passthrough extra['tools'] escape hatch (no top-level tool fields on AntigravityConfig): Removing 'tools' from ANTIGRAVITY_MANAGED_EXTRA gives callers direct control over wire server tools via AntigravityConfig(extra={'tools': [...]}) while keeping tools= strictly at ai.generate(tools=...). Any extra['tools'] entries precede request.tools on the wire. extra={'tools': []} and non-list extra['tools'] fail closed with INVALID_ARGUMENT because the API reads tools: [] as unset (proto3 repeated field) and turns all three built-in tools back on.
  • Swap antigravity-preview-05-2026 for antigravity-preview-09-2026 in KNOWN_ANTIGRAVITY_MODELS: 05-2026 was shut down upstream; 09-2026 replaces it in Dev UI action listings and test fixtures.

Why not disable_* booleans?

We initially prototyped opt-out flags (disable_google_search, disable_url_context, disable_code_execution). On the surface that looks ergonomic for "keep defaults except bash" (AntigravityConfig(disable_code_execution=True)), because Antigravity enables all three when tools is omitted.

In practice, disable_* forces Genkit to hardcode the server's default tool catalog (('google_search', 'url_context', 'code_execution')) and synthesize the complement list client-side. That creates high ongoing maintenance burden and puts Genkit maintainers in the middle as a blocking dependency before future upstream features work:

  • Genkit becomes a release bottleneck for every new server tool or sub-option: Under disable_* (with extra['tools'] blocked), callers cannot attach an mcp_server, pass search_types to google_search, or use a newly launched Interactions server tool until we add dedicated config fields, wire bespoke merge rules, and cut a release:
    # With disable_*: blocked on a Genkit SDK release for every new tool or sub-option
    config = AntigravityConfig(
        disable_code_execution=True,
        # Nowhere to pass google_search.search_types, mcp_server, or a new server tool
        # without inventing more flat fields and client-side list synthesis.
    )
    
    # With extra={'tools': [...]}: works on day zero with zero SDK changes
    config = AntigravityConfig(
        extra={
            'tools': [
                {'type': 'google_search', 'search_types': ['web_search']},
                {'type': 'url_context'},
                {'type': 'mcp_server', 'name': 'pos', 'url': 'https://pos.example/mcp'},
                {'type': 'new_server_tool', 'mode': 'strict'},
            ]
        },
    )
  • Client-synthesized complements drift silently when server defaults change: If Antigravity enables a fourth default tool upstream, disable_code_execution=True still sends tools: [{'type': 'google_search'}, {'type': 'url_context'}] and silently turns off that fourth tool even though the caller never asked to disable it. With extra={'tools': [...]}, the wire contract is transparent: omit tools for server defaults, or pass the exact list of tools the agent may run.
  • Additive + subtractive fields collide: Once mcp_server and ai.generate(tools=...) function tools enter the picture, mixing disable_* flags with additive tool lists forces non-obvious implicit rules ("does adding an MCP server or function tool keep all three built-ins unless disable_* is also set?"). Explicit passthrough + concatenation ([*extra_tools, *function_tools]) avoids hidden synthesis rules.

Verified live

Ran each case against antigravity-preview-09-2026 with the agent listing its available tools:

  • no tools -> execute_bash, google:search, google:browse, plus sandbox file tools
  • tools: [{'type': 'google_search'}, {'type': 'url_context'}] -> execute_bash gone; search, browse, file tools stay
  • tools: [{'type': 'code_execution'}] -> search and browse gone
  • tools: [] / tools: null -> same as no tools (all three on)

Breaking changes

None for tools: ai.generate(tools=...) and extra['tools'] both previously raised INVALID_ARGUMENT on Antigravity. In KNOWN_ANTIGRAVITY_MODELS, antigravity-preview-05-2026 (shipped in v0.12.0) is replaced by antigravity-preview-09-2026 because 05-2026 is shut down upstream.

Cross-SDK

Matches JS (js/plugins/google-genai/src/googleai/antigravity.ts and js/plugins/google-genai/src/common/interaction-converters.ts, #6807): AntigravityConfigSchema passes server tools via .passthrough() (extra={'tools': [...]} in Python), appends request.tools after config.tools, filters resolved sandbox function_call steps via serverFunctionCall, and continues stored multi-turn interactions via previous_interaction_id and environment_id.

@github-actions github-actions Bot added docs Improvements or additions to documentation python Python labels Nov 2, 2026

@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 built-in tools (google_search, url_context, and code_execution) for the Antigravity model in the Genkit Google Genai package. It updates the AntigravityConfig to include these tools as flat configuration fields, refactors the tool building logic to use a shared utility, and updates the corresponding documentation and tests to reflect these changes. As there were no review comments provided, I have no feedback to offer.

@huangjeff5
huangjeff5 requested a review from hilariie November 2, 2026 12:07
@huangjeff5
huangjeff5 added this pull request to stack #7023 November 2, 2026 18:32
Base automatically changed from fix/py-interactions-config-strict to main November 2, 2026 22:06
@huangjeff5
huangjeff5 force-pushed the feat/py-antigravity-builtin-tools branch from 3519c3c to 99b73af Compare November 2, 2026 22:06

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

A few comments/questions

@huangjeff5 huangjeff5 changed the title feat(py/google-genai): AntigravityConfig takes code_execution, google_search and url_context feat(py/google-genai): AntigravityConfig takes disable_google_search, disable_url_context and disable_code_execution Nov 3, 2026
@huangjeff5
huangjeff5 force-pushed the feat/py-antigravity-builtin-tools branch from d973c37 to 86b17e4 Compare November 4, 2026 19:23
@huangjeff5 huangjeff5 changed the title feat(py/google-genai): AntigravityConfig takes disable_google_search, disable_url_context and disable_code_execution feat(py/google-genai): AntigravityConfig takes tools allowlist and moves to 09-2026 Nov 4, 2026
@huangjeff5 huangjeff5 changed the title feat(py/google-genai): AntigravityConfig takes tools allowlist and moves to 09-2026 feat(py/google-genai): allow Antigravity extra['tools'] passthrough and move to 09-2026 Nov 4, 2026
@huangjeff5
huangjeff5 force-pushed the feat/py-antigravity-builtin-tools branch from 86b17e4 to d64cc2c Compare November 4, 2026 19:43
@huangjeff5 huangjeff5 changed the title feat(py/google-genai): allow Antigravity extra['tools'] passthrough and move to 09-2026 feat(py/google-genai): wire Antigravity tools, multi-turn continuation, and 09-2026 Nov 4, 2026
@huangjeff5
huangjeff5 force-pushed the feat/py-antigravity-builtin-tools branch from d64cc2c to 0940322 Compare November 4, 2026 20:53
@huangjeff5
huangjeff5 merged commit ceabe10 into main Nov 4, 2026
27 checks passed
@huangjeff5
huangjeff5 deleted the feat/py-antigravity-builtin-tools branch November 4, 2026 21:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation python Python

Projects

None yet

3 participants