Antigravity Environment Config (Interactions)
Configure the Antigravity sandbox by reusing an environment ID or passing a full EnvironmentConfig dict.
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). State remains available while that environment ID is valid; inactive environments expire. |
Full EnvironmentConfig dict | Need a specific source repo, package set, or network policy. |
The dict shape follows Google's environment schema. Only the keys you set are sent; the API applies defaults for the rest.
Code
from os import getenv
from agno.agent import Agent
from agno.models.google import GeminiInteractions
# Reuse an existing environment by id
agent_reuse = Agent(
model=GeminiInteractions(
agent="antigravity-preview-05-2026",
environment=getenv("ANTIGRAVITY_ENVIRONMENT_ID"),
),
markdown=True,
)
# Full EnvironmentConfig
agent_custom = Agent(
model=GeminiInteractions(
agent="antigravity-preview-05-2026",
environment={
"type": "remote",
"sources": [
{"type": "repository", "source": "https://github.com/agno-agi/agno", "target": "/workspace/agno"},
],
},
),
markdown=True,
)
if __name__ == "__main__":
# Reuse is optional: supply a real, still-valid ID to run this part.
if getenv("ANTIGRAVITY_ENVIRONMENT_ID"):
agent_reuse.print_response(
"Continue the project we started last time and ship the next "
"iteration of the report."
)
agent_custom.print_response(
"Skim the repo we cloned, summarize the module layout, and save "
"the summary to STRUCTURE.md inside the sandbox."
)The script always runs the custom repository example. To run the reuse example too, set ANTIGRAVITY_ENVIRONMENT_ID to an existing environment ID. Omitted network configuration uses the provider default; use its documented network.allowlist when restricting outbound access.
Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateSet your API key
export GOOGLE_API_KEY=xxxInstall dependencies
uv pip install -U "google-genai>=2.3" agnoRun Agent
Save the code above as antigravity_environment_config.py, then run:
python antigravity_environment_config.py