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.

Antigravity222Managed AgentsGemini API2Agents9SandboxPython12

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 QUEUEDRUNNINGSUCCEEDED (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

Agents & Manager2026-04-08
Antigravity AgentKit 2.0 Runtime Errors: Complete Troubleshooting Guide — tool_call Failures, Infinite Loops, and Context Overflow
A comprehensive guide to diagnosing and fixing AgentKit 2.0 runtime errors in production: tool_call failures, infinite loop detection, context window overflow, parallel agent sync errors, and graceful degradation patterns — all with working code.
Agents & Manager2026-04-29
Teaching Antigravity Agents to Learn from Failure — A Solo Developer's Loop for Reusing Failure History
Antigravity agents repeat the same mistakes because each session starts blank. A solo developer's six-month run with a structured failure log, a separate observer agent, and the side-effect of overfitting.
Agents & Manager2026-04-27
Letting Antigravity Be Your Night-Shift Engineer: A Solo Dev Operating Model
How to operate Antigravity agents as the second engineer who works while you sleep. Task hand-off, scope boundaries, and a five-minute morning review — the model I have refined while running multiple products solo.
📚RECOMMENDED BOOKS
Build a Large Language Model (From Scratch)
Sebastian Raschka
LLM Dev
Prompt Engineering for LLMs
Berryman & Ziegler
Prompting
AI Engineering
Chip Huyen
AI Eng
* Contains affiliate links
See all →