ANTIGRAVITY LABJP
Articles/Agents & Manager
Agents & Manager/2026-06-15Advanced

Calling a Managed Antigravity Agent from the Gemini API: Design Notes on the Preview Model

antigravity-preview-05-2026, now in public preview on the Gemini API, is a Managed Agent that plans, runs code, edits files, and browses the web autonomously inside a sandbox. Here is how it differs from rolling your own orchestration, and where to draw the line.

managed-agent2gemini-api7antigravity436agent-design9automation87

Premium Article

Until now, as an indie developer, whenever I handed work to an agent, I built the plan-act-verify loop in my own code. Send a prompt, interpret the tool calls that come back, return results, send again. It works, but the burden of state management and retries is entirely mine.

antigravity-preview-05-2026, which entered public preview on the Gemini API in June, is the option that shoves most of that burden onto the server side. It is a Managed Agent that autonomously runs planning, reasoning, code execution, file edits, and web browsing inside a sandbox. The caller hands over a goal and waits for the result.

Convenient as that is, it demands a design decision: what to entrust to the Managed side, and what to keep in hand. Leave that vague and you end up with both cost and control half-baked. This article organizes that line, with implementation alongside.

The responsibility boundary

First, the two are not competitors; they sit at different layers. My breakdown is this.

  • Keep in hand: when to start (scheduling), what goal to hand over, and how to verify and absorb the result. This is business logic and cannot leave your side.
  • Entrust to the Managed side: the intermediate steps toward the goal. Writing files, trying commands, switching tactics on failure: the trial-and-error loop itself.

Put another way, the Managed Agent takes on "how," while you focus on "what, when, and how to receive it." The thing I sweated most when writing tool loops by hand was the intermediate state management, so losing that is significant.

That said, you should not entrust everything. Output verification stays in hand. The agent saying "done" is one thing; trusting that and pushing it to production is another.

Start from the smallest call

Begin by specifying the preview model name and handing over a single goal. Here is a Node example.

import { GoogleGenerativeAI } from "@google/generative-ai";
 
const genai = new GoogleGenerativeAI(process.env.GEMINI_API_KEY);
 
// A Managed Agent starts as a long-running, sandboxed job
async function startAgentJob(goal) {
  const model = genai.getGenerativeModel({
    model: "antigravity-preview-05-2026",
  });
 
  const job = await model.startAgentTask({
    goal,
    sandbox: { filesystem: true, network: "restricted" },
    maxSteps: 24,            // always set a ceiling to stop runaways
  });
 
  return job.id;             // do not wait synchronously; take the job ID
}

Two points matter here. Always set a ceiling with maxSteps. And do not wait for the result synchronously; take a job ID and fetch it later. A Managed Agent can run for minutes, and holding an HTTP request open that long is not realistic.

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
The responsibility boundary between a Managed Agent and your own orchestration, and how to decide what goes where
An implementation pattern for calling antigravity-preview-05-2026 and polling long-running tasks
The sandbox, cost, and idempotency traps you actually hit, and how I avoid them in operation
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-06-15
Treating the Managed Agent as a Cost-Capped Throwaway Worker: Isolating Untrusted Input from Production
How to use the Managed Antigravity Agent, now in Gemini API public preview, as a throwaway worker that is born and discarded per request. Cost caps, isolation, and idempotency with implementation steps.
Agents & Manager2026-06-16
Generating Multilingual Release Notes with the Managed Antigravity Agent via the Gemini API
A hands-on record of building a pipeline that turns git commit logs into multilingual App Store and Google Play release notes using the Managed Antigravity Agent, now in public preview through the Gemini API.
Agents & Manager2026-07-01
It Worked Interactively but Went Silent Overnight — Making an Antigravity Agent Behave the Same in the Desktop and the CLI
An agent that runs perfectly in the Antigravity desktop app but does nothing when you schedule it through the CLI. This walks through absorbing the gap between interactive and unattended runs across four points — approvals, context, secrets, and runtime — with working code and a preflight check, so one definition behaves identically on both.
📚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 →