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-agentgemini-api5antigravity350agent-design2automation42

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-12
Handing Dependency Updates to Antigravity Agents — Risk Tiers, Verification, and Rollback
How far can you trust Antigravity agents with dependency updates? A four-tier risk model that corrects semver optimism, worktree-isolated lots, a fixed verification script, and a rollback-first ledger — the operations design I settled on while maintaining multiple apps.
Agents & Manager2026-05-22
Three Weeks of Letting Antigravity's Background Agent Handle Nightly Wallpaper Asset Updates
A quiet field log from three weeks of delegating the nightly asset pipeline of a wallpaper app to Antigravity's Background Agent. Where it earned its keep, where I still need a human hand, and the small routines that made the morning check feel light.
Agents & Manager2026-04-20
Building a Business Automation Agent with Antigravity × Google Workspace API — Complete Gmail, Drive, Sheets & Docs Integration
Learn how to build AI agents that automate Gmail responses, generate documents from Drive templates, and create intelligent Sheets reports using Antigravity, Google Workspace APIs, and Gemini.
📚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 →