Antigravity Environment Config (Interactions)
Two non-default ways to control the Antigravity sandbox:
| Option | When 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 dict | Need 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 Agent2from kern.models.google import GeminiInteractions34# Reuse an existing environment by id5agent_reuse = Agent(6 model=GeminiInteractions(7 agent="antigravity-preview-05-2026",8 environment="env_xxxxxxxx",9 ),10 markdown=True,11)1213# Full EnvironmentConfig14agent_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)2728if __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 )3334 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.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateSet your API key
1export GOOGLE_API_KEY=xxxInstall dependencies
1uv pip install -U "google-genai>=2.0" kern-aiRun Agent
1python cookbook/90_models/google/gemini_interactions/antigravity_environment_config.py