Antigravity Environment Config (Interactions)

Two non-default ways to control the Antigravity sandbox:

OptionWhen to use
Reuse by id ("env_<id>")Agent needs to build on prior work in the same sandbox (iterative project). Faster startup, state persists across runs.
Full EnvironmentConfig dictNeed a specific source repo, package set, or network policy.

The dict shape mirrors the API's EnvironmentConfig. Only the keys you set are sent; the API applies defaults for the rest.

Code

1from kern.agent import Agent
2from kern.models.google import GeminiInteractions
3
4# Reuse an existing environment by id
5agent_reuse = Agent(
6 model=GeminiInteractions(
7 agent="antigravity-preview-05-2026",
8 environment="env_xxxxxxxx",
9 ),
10 markdown=True,
11)
12
13# Full EnvironmentConfig
14agent_custom = Agent(
15 model=GeminiInteractions(
16 agent="antigravity-preview-05-2026",
17 environment={
18 "type": "remote",
19 "sources": [
20 {"type": "git", "url": "https://github.com/kern-ai/kern"},
21 ],
22 "network": {"allow_internet_access": True},
23 },
24 ),
25 markdown=True,
26)
27
28if __name__ == "__main__":
29 agent_reuse.print_response(
30 "Continue the project we started last time and ship the next "
31 "iteration of the report."
32 )
33
34 agent_custom.print_response(
35 "Skim the repo we cloned, summarize the module layout, and save "
36 "the summary to STRUCTURE.md inside the sandbox."
37 )

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Set your API key

1export GOOGLE_API_KEY=xxx

Install dependencies

1uv pip install -U "google-genai>=2.0" kern-ai

Run Agent

1python cookbook/90_models/google/gemini_interactions/antigravity_environment_config.py