◉ANTIGRAVITY LABJP
Articles/Agents & Manager
◈ Agents & Manager/2026-06-12Intermediate

Running Gemini's Managed Agents API: Where Cloud Execution Ends and My Local Agents Begin

A hands-on record of launching Gemini's Managed Agents (public preview) from Python — polling, artifact retrieval, and a cost guard — plus five criteria I use to decide what stays on my local CLI agents.

Antigravity399Managed Agents5Gemini API5Agents25SandboxPython24

✦ Premium Article

With the June 18 shutdown of Gemini CLI approaching, I had been steadily migrating my local scripts over to Antigravity CLI. Partway through that work, something else caught my attention: Managed Agents, the public-preview layer that landed on the Gemini API side.

One API call. Behind it, reasoning, tool use, and code execution — all inside an isolated Linux environment. I knew the outline from the I/O 2026 announcements, but actually running it produced two competing reactions: "this overlaps with my local agent setup" and "no, this deserves to be treated as something else entirely."

After a few days of moving real jobs across, I have settled on a third view: draw the boundary properly and you will not want to give up either side. This article is the record of that experiment. All code reflects the public preview as of this writing (June 12, 2026); field names and behavior may change before GA.

What Managed Agents actually takes off your plate

Antigravity 2.0 spans five surfaces: the desktop app, the CLI, the SDK, the Managed Agents API, and the enterprise path. The first three are entry points for running agents on your own machine. Managed Agents is different in kind — the execution environment itself lives on Google's infrastructure.

You make one call. On the other side, Gemini 3.5 Flash reasons, uses tools as needed, executes code in an isolated Linux sandbox, and hands back the results.

Building that yourself means owning Docker containers, per-run cleanup, privilege separation, and network restrictions. As an indie developer I ran an isolated execution setup for my publishing pipeline in self-managed containers for a while, and the scaffolding for "don't break anything, don't leak anything" ended up larger than the actual job logic. Moving that entire perimeter to the far side of an API is, to me, the real point of this feature.

What it is not suited for is interactive work that reads deeply through a local repository. I will come back to that boundary later.

The minimal launch: a run is a job, not a request

This was the first mental shift. Unlike a synchronous generateContent call, a Managed Agents execution is an asynchronous job. You submit it, get back a run ID, and the state moves through QUEUED → RUNNING → SUCCEEDED (or FAILED / TIMED_OUT).

Here is a small job that audits dependency upgrades:

import os
from google import genai
 
client = genai.Client(api_key=os.environ["GOOGLE_API_KEY"])
 
run = client.agents.runs.create(
    model="gemini-3.5-flash",
    instructions=(
        "Read the uploaded package.json and produce a Markdown list of "
        "major-version upgrade candidates, with brief compatibility notes."
    ),
    input_files=["./package.json"],
    sandbox={"timeout_seconds": 600},
    metadata={"job": "dep-audit-2026-06-12"},
)
 
print(run.id, run.state)  # e.g. runs/8f3c... QUEUED

What this solves: launching a code-execution-backed research job with zero environment setup. sandbox.timeout_seconds is the server-side execution cap. The metadata job name is there for idempotency, which I will get to shortly.

In my environment, the time from submission to sandbox acquisition (the transition to RUNNING) averaged around 8 seconds. That is comparable to spinning up a local Docker container. I had braced for cold-start pain and was pleasantly surprised.

✦

Thank you for reading this far.

Continue Reading

What follows includes implementation code, benchmarks, and practical content we hope you'll find useful. This site runs without ads — server and development costs are supported entirely by members like you. If it's been helpful, we'd be truly grateful for your support.

WHAT YOU'LL LEARN
✦Follow a working Python implementation from launching a Managed Agents run to polling and artifact retrieval
✦See how I handled the 3 operational essentials in code: timeouts, idempotency, and a token budget guard
✦Get the 5 criteria I use to split jobs between Google's isolated sandbox and my local CLI agents
Secure payment via Stripe · Cancel anytime
✦

Unlock This Article

Get full access to the rest of this article. Buy once, read anytime. This site is ad-free — your support goes directly toward keeping it running.

or
Unlock all articles with Membership →
Share

Thank You for Reading

Antigravity Lab is ad-free, supported entirely by members like you. We publish practical guides daily with implementation code, benchmarks, and production-ready patterns. If you've found it useful, we'd love to have you on board.

  • ✦Copy-paste ready implementation code
  • ✦New advanced guides published daily
  • ✦$5/mo or $10 for lifetime access
View Membership →

Related Articles

⬡ Integrations2026-09-20
antigravity-preview-05-2026 shuts down October 5: which setups need more than a string swap
The shutdown date for antigravity-preview-05-2026 is set for October 5, and the official page gives you the date and the successor name, nothing more. If you only read output_text, swapping the string is the whole migration. If you read steps, it is not.
◈ Agents & Manager2026-10-22
17 Dead References in My Handover Docs Turned Out to Be 2 Files, and the Real Risk Was a Different Site's Playbook Mixed In
The full Python script I use to check the root .md files an agent reads. My naive version counted 17 dead references; fixed, it was 7 across 2 files. Then it missed the real problem. Here is how I found it.
◈ Agents & Manager2026-10-16
Before Handing an Agent a .zip: Dropping .git Cut 29 MB to 15 MB, and 28 Secret Warnings Turned Out to Be Noise
Antigravity app v2.23.0 lets you attach a .zip. I packed my own repository to count what .git weighs and how many secret-scan warnings are false alarms, and I leave the full Python script that excludes, scans, and writes a manifest.