How Gemini Managed Agents Works under the Hood You can go from zero to a working agent in five lines. One API call, and the response comes back with a finished PDF, charts, and a summary. Python from google import genai client = genai.Client() interaction = client.interactions.create( agent="antigravity-preview-05-2026", input="Analyze the latest lego set data and create a PDF report with charts", environment="remote", ) print(interaction.output_text) What most people miss: this is not a single model call that returns text. Behind that one call, a sandbox boots, skills get loaded, and the model enters a loop where it reasons, picks tools, executes code, reads the output, and repeats until the task is done. The Execution Loop, Step by Step interactions.create() does more than send a prompt. It spins up a full execution environment. User Your code Gemini API Orchestrator Gemini 3.5 Flash Reasoning Sandbox Linux VM You send a prompt to the Gemini API The API boots a sandbox, routes your prompt to the model, dispatches tool calls, and collects results Gemini 3.5 Flash plans and picks tools, looping until the task is complete Code runs inside an isolated Linux VM, not on your machine Prompt Write a python script that prints hello world and execute it. Explore each step Request: Your prompt hits the Interactions API via HTTPS. The API accepts it and starts orchestrating the interaction server-side. 1 / 10 Inside the Sandbox Each interaction gets its own isolated Linux container. The agent can install packages, run scripts, read and write files, and browse the web. The sandbox runs Ubuntu with 4 vCPU and 16 GB RAM. Environment compute is not billed during preview (you pay only for model tokens). Environments can persist across interactions. The first call returns an environment_id you pass back to keep files and state intact. See the Environments documentation for sources, networking, and lifecycle details. Python # Turn 1: sandbox is created i1 = client.interactions.create( agent="antigravity-preview-05-2026", input="Install pandas and create analysis.py", environment="remote", ) # Turn 2: same sandbox, files persist i2 = client.interactions.create( agent="antigravity-preview-05-2026", input="Run analysis.py on the Q1 data", environment=i1.environment_id, previous_interaction_id=i1.id, ) From Prompt to Production Agent The execution loop is the same whether you are experimenting or running in production. The difference is how much configuration you want to provide upfront. Ad-hoc call: Send a input with environment="remote". Python interaction = client.interactions.create( agent="antigravity-preview-05-2026", input="Write a Python script that prints hello world", environment="remote", ) Add instructions and skills: Use system_instruction or AGENTS.md to customize behavior and provide skills via sources. Python interaction = client.interactions.create( agent="antigravity-preview-05-2026", input="Analyze Q1 revenue and create a slide deck.", system_instruction="You are a data analyst. Export results as PDF.", environment={ "type": "remote", "sources": [ {"type": "inline", "target": ".agents/AGENTS.md", "content": "Always use matplotlib for charts."}, {"type": "inline", "target": ".agents/skills/slides/SKILL.md", "content": "---\nname: slides\n---\n# Slide Maker\nCreate HTML decks."}, ], }, ) Save as a managed agent: Once your setup is stable, persist it with client.agents.create(). Each invocation forks a fresh sandbox from the base environment. Python agent = client.agents.create( id="data-analyst", base_agent="antigravity-preview-05-2026", system_instruction="You are a data analyst. Export results as PDF.", base_environment={ "type": "remote", "sources": [ {"type": "repository", "source": "https://github.com/my-org/templates", "target": "/workspace/templates"}, ], }, ) Invoke by ID: Reference the agent ID on every call. Same loop, no config to repeat. Python result = client.interactions.create( agent="data-analyst", input="Analyze Q1 revenue data and create a slide deck.", environment="remote", ) print(result.output_text) Where to go next Managed Agents Developer Guide Try in AI Studio Quickstart Build Custom Agents Environments Interactions API