https://x.com/i/article/2099964776117899264
Managed Agents in the Gemini API: an updated agent harness, a Files API, and managed credentials
Gemini managed agents are getting an updated harness. antigravity-preview-09-2026 brings the agent's tools and behavior closer to what you get in the Antigravity Coding Agent, it's live today in the Interactions API and AI Studio, and runs on Gemini 3.8 Flash with the model configurable per interaction.
We're also shipping two new APIs that make building with managed agents easier and more secure. A Files API for getting data in and out of the agent's environment, and a Credentials API so the agent can use the services you already use, from MCP servers to third-party APIs, in a secure way.
Gemini managed agents: Antigravity in the Gemini API
A single API call gives you an Gemini agent that reasons, executes code, manages files, and browses the web inside an isolated Linux sandbox hosted by Gemini API. You send a prompt; the agent plans, acts, observes the results, and repeats until the task is done.
The sandbox persists across turns, and the agent is equipped with tools for:
- code_execution: runs bash in the sandbox, so Python, Node, git, and anything you can do in a terminal one command away.
- Filesystem tools, enabled with environment, read, write, edit, search, and list files.
- google_search and url_context for the web.
- Automatic context compaction at around 135k tokens, so long sessions keep going.
- Custom function tools and remote mcp_server tools when you need your own systems.
You can configure the harness via agent_config, model changes the underlying Gemini model and max_total_tokens caps how much a single run can spend. tools allows you to customize what the agent can do. You can pass all of this inline on each interaction, or save it once as a managed agent with agents.create() and call it by id. Here's a cheap research agent that can only search and read the web.
What improved in antigravity-preview-09-2026
- Better caching on long conversations. Cache hit rate is up 7% on multi-turn coding and research tasks and 16% on long question-answering runs.
- Cheaper, more accurate edits. Based on internal evals, 40% fewer output tokens on file edits and up to ~8% higher task completion completion on multi-turn software engineering and research tasks.
- New tools. Requests that work on antigravity-preview-05-2026 work unchanged. Tool names in step events have changed (file tools now report as view_file, write_to_file, and replace_file_content, for example), so update any code that filters on them.
Files API: get data in, get results out
Agents create files and work with files, a CSV you hand them, a report they write, a repo they clone. The Files API makes moving those in and out of an agent's environment simple. Your first interaction creates the sandbox and returns its environment_id; from then on you can list what's there, upload into it, and download individual files or directories.
Here's an example: Hand the agent a CSV, ask for a self-contained HTML dashboard, pull the file out.
The environment persists, so the next interaction can build on it. Upload new data with files.upload() and continue the conversation.
Credentials API: Secrets the model never sees
Agents get useful when they can reach the services you already use, an MCP server, a SaaS API, an internal tool behind OAuth. All of those need credentials.
The Credentials API extends our initial secrets support into a full API, so you can avoid passing clear-text tokens in every request. You register a credential once with credentials.create(); we store it encrypted and only put it on the wire, for the destination you defined. It supports 3 types of credentials
- bearer_token for MCP servers and APIs that take an Authorization header (header name and prefix are configurable)
- environment_variable for anything the agent calls from the sandbox with curl, requests, or an SDK, scoped to trusted_domains
- oauth2 for providers that hand out refresh tokens; we refresh the access token before it expires and store a rotated refresh token if the provider sends one
A credential can go in three places. Attach it to a remote mcp_server tool, and the Gemini API adds the Authorization header when it calls that server, bind it to an environment variable in the sandbox and the container gets a placeholder that the egress proxy swaps for the real value on the way out, or simply create a mutation rule for headers at egress for a specific domain.
No credentials live in the environment: not in memory, not in stdout, not in the model's context. If the agent gets tricked into sending $SLACK_BOT_TOKEN to a host outside trusted_domains, the proxy sees an unreplaced placeholder and returns 403. Read the Credentials docs to learn more about injection_location, wildcard domains, and OAuth2 setup.
Start building
Switch to antigravity-preview-09-2026 today, with the Python or JavaScript SDK or REST. Pricing is unchanged and benefit from:
- Updated harness: Sandbox, filesystem tools, bash, Google Search, context compaction, configurable model. Better caching than the first preview.
- Files API: Upload into a running sandbox, list what the agent wrote, download the one file you need.
- Credentials API: Register a secrets once, attach it to an MCP server or a sandbox env var, and the model never sees it.
Note: antigravity-preview-05-2026 will be deprecated on October 5, 2026. After that date, requests to it are redirected to the updated harness. We'll track the date in the changelog.
