Antigravity Multi-turn (Interactions)
Continue an Antigravity interaction across turns using previous_interaction_id and a database.
Continue an Antigravity interaction across turns. Each response carries an interaction_id; the next turn references it via previous_interaction_id so only the new user message is sent on the wire. Conversation history and sandbox files have separate identities. Reuse the returned environment ID so follow-up turns can access files from the first turn.
Persisting the interaction ID requires a database. The assistant message stores it under provider_data, and the next turn reads it back.
The current Agno response metadata exposes interaction_id, but not environment_id. Retrieve the raw interaction to read the environment ID, then use it on later calls. environment="remote" requests a fresh sandbox. Keep the same agent session, and do not share this mutable model between concurrent conversations. See Google environments.
Code
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.google import GeminiInteractions
model = GeminiInteractions(
agent="antigravity-preview-05-2026",
environment="remote",
)
agent = Agent(
model=model,
add_history_to_context=True,
db=SqliteDb(db_file="tmp/data.db"),
markdown=True,
)
if __name__ == "__main__":
response = agent.run(
"Plot the growth of global solar energy generation over the last "
"decade and save the plot as solar.png in the sandbox."
)
interaction_id = (response.model_provider_data or {}).get("interaction_id")
if not interaction_id:
raise RuntimeError("The first run did not return an interaction ID")
interaction = model.get_client().interactions.get(interaction_id)
environment_id = getattr(interaction, "environment_id", None)
if not environment_id:
raise RuntimeError("No reusable sandbox was returned")
model.environment = environment_id
print(response.content)
agent.print_response(
"Take solar.png and produce a 3-slide HTML deck that embeds it, "
"with a title slide and a short takeaway per slide."
)
agent.print_response(
"Review the deck for clarity and tighten the takeaways. Save the "
"revised version as deck_v2.html."
)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" sqlalchemy agnoRun Agent
Save the code above as antigravity_multi_turn.py, then run:
python antigravity_multi_turn.py