Com os agentes gerenciados na API Gemini, é possível ampliar o agente Antigravity com suas próprias instruções, habilidades e dados. É possível personalizar o agente inline no momento da interação ou salvar a configuração como um agente gerenciado que você invoca por ID.
Personalizar o agente do Antigravity
A maneira mais rápida de criar um agente personalizado é transmitir sua configuração inline ao criar uma nova interação sem precisar fazer um registro. É possível estender o agente de três maneiras:
- Instruções do sistema: transmita texto in-line via
system_instructionpara moldar o comportamento. - Ferramentas: substitua as ferramentas padrão (execução de código, pesquisa, contexto de URL), registre servidores MCP remotos ou defina funções personalizadas (chamada de função).
- Arquivos e habilidades: monte arquivos como
AGENTS.mdeSKILL.mdno ambiente.
Confira um exemplo de como transmitir os três inline:
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Analyze the Q1 revenue data and create a slide deck.",
system_instruction="You are a data analyst. Always include visualizations and export results as PDF.",
environment={
"type": "remote",
"sources": [
{
"type": "inline",
"target": ".agents/AGENTS.md",
"content": "Always use matplotlib for charts. Include a summary table in every report.",
},
{
"type": "inline",
"target": ".agents/skills/slide-maker/SKILL.md",
"content": "---\nname: slide-maker\n---\n# Slide Maker\nCreate HTML slide decks from data analysis results.",
},
],
},
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Analyze the Q1 revenue data and create a slide deck.",
system_instruction: "You are a data analyst. Always include visualizations and export results as PDF.",
environment: {
type: "remote",
sources: [
{
type: "inline",
target: ".agents/AGENTS.md",
content: "Always use matplotlib for charts. Include a summary table in every report.",
},
{
type: "inline",
target: ".agents/skills/slide-maker/SKILL.md",
content: "---\nname: slide-maker\n---\n# Slide Maker\nCreate HTML slide decks from data analysis results.",
},
],
},
}, { timeout: 300000 });
console.log(interaction.output_text);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Analyze the Q1 revenue data and create a slide deck.",
"system_instruction": "You are a data analyst. Always include visualizations and export results as PDF.",
"environment": {
"type": "remote",
"sources": [
{
"type": "inline",
"target": ".agents/AGENTS.md",
"content": "Always use matplotlib for charts. Include a summary table in every report."
},
{
"type": "inline",
"target": ".agents/skills/slide-maker/SKILL.md",
"content": "---\nname: slide-maker\n---\n# Slide Maker\nCreate HTML slide decks from data analysis results."
}
]
}
}'
Tudo é definido no momento da interação. Não é necessário registrar nada primeiro. A estrutura do agente Antigravity fornece o tempo de execução (execução de código, gerenciamento de arquivos, acesso à Web) e suas camadas de configuração.
Ferramentas e instruções do sistema
É possível personalizar o comportamento e os recursos do agente para uma interação específica usando os parâmetros system_instruction e tools.
- Instruções do sistema: use o parâmetro
system_instructionpara transmitir texto inline que molda o comportamento do agente. Isso é ideal para ajustes rápidos que você quer mudar por chamada. Ossystem_instructioneAGENTS.mdsão cumulativos. Ambos se aplicam quando estão presentes. - Ferramentas: por padrão, o agente Antigravity tem acesso a
code_execution,google_searcheurl_context. É possível substituir essa lista transmitindo o parâmetrotoolsno momento da interação. Também é possível registrar servidores MCP remotos ou definir funções personalizadas (chamada de função) para conectar o agente às suas próprias APIs e bancos de dados. Para mais detalhes sobre as ferramentas disponíveis, consulte Agente antigravidade: ferramentas compatíveis.
Personalização baseada em arquivos
Estrutura de diretórios do agente
Embora seja possível transmitir a configuração inline, recomendamos organizar os arquivos do agente em um diretório estruturado. Isso facilita o gerenciamento, o controle de versões e a montagem no ambiente do agente.
Um diretório de projeto de agente típico tem esta aparência:
my-agent/
├── AGENTS.md # Instructions on how the agent should operate
├── skills/ # Custom skills (subfolders and SKILL.md files)
│ └── slide-maker/
│ └── SKILL.md
└── workspace/ # Initial data files and knowledge
O ambiente de execução do Antigravity verifica .agents/ (e a raiz do ambiente) em busca desses arquivos.
AGENTS.md
O agente carrega automaticamente .agents/AGENTS.md (ou /.agents/AGENTS.md) do ambiente como instruções do sistema na inicialização. Use AGENTS.md para definições de personas longas, diretrizes detalhadas e instruções que você quer controlar a versão junto com o código.
Faça a montagem de um AGENTS.md usando uma origem inline:
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Analyze the Q1 revenue data and create a report.",
system_instruction="You are a data analyst. Always include visualizations and export results as PDF.",
environment={
"type": "remote",
"sources": [
{
"type": "inline",
"target": ".agents/AGENTS.md",
"content": "Always use matplotlib for charts. Include a summary table in every report.",
},
],
},
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Analyze the Q1 revenue data and create a report.",
system_instruction: "You are a data analyst. Always include visualizations and export results as PDF.",
environment: {
type: "remote",
sources: [
{
type: "inline",
target: ".agents/AGENTS.md",
content: "Always use matplotlib for charts. Include a summary table in every report.",
},
],
},
}, { timeout: 300000 });
console.log(interaction.output_text);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Analyze the Q1 revenue data and create a report.",
"system_instruction": "You are a data analyst. Always include visualizations and export results as PDF.",
"environment": {
"type": "remote",
"sources": [
{
"type": "inline",
"target": ".agents/AGENTS.md",
"content": "Always use matplotlib for charts. Include a summary table in every report."
}
]
}
}'
Habilidades: SKILL.md
As habilidades são arquivos que ampliam os recursos do agente. Coloque-os em .agents/skills/<skill-name>/SKILL.md. O conector vai descobrir e registrar automaticamente.
.agents/
├── AGENTS.md
└── skills/
└── slide-maker/
└── SKILL.md
Monte uma habilidade usando uma origem inline:
Python
from google import genai
client = genai.Client()
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Create a presentation about our Q1 results.",
system_instruction="You create presentations from data.",
environment={
"type": "remote",
"sources": [
{
"type": "inline",
"target": ".agents/skills/slide-maker/SKILL.md",
"content": "---\nname: slide-maker\ndescription: Create HTML slide decks\n---\n# Slide Maker\n\nWhen asked to create a presentation:\n1. Analyze the input data\n2. Create an HTML slide deck with reveal.js\n3. Save to /workspace/output/slides.html",
},
],
},
)
print(interaction.output_text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Create a presentation about our Q1 results.",
system_instruction: "You create presentations from data.",
environment: {
type: "remote",
sources: [
{
type: "inline",
target: ".agents/skills/slide-maker/SKILL.md",
content: "---\nname: slide-maker\ndescription: Create HTML slide decks\n---\n# Slide Maker\n\nWhen asked to create a presentation:\n1. Analyze the input data\n2. Create an HTML slide deck with reveal.js\n3. Save to /workspace/output/slides.html",
},
],
},
}, { timeout: 300000 });
console.log(interaction.output_text);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Create a presentation about our Q1 results.",
"system_instruction": "You create presentations from data.",
"environment": {
"type": "remote",
"sources": [
{
"type": "inline",
"target": ".agents/skills/slide-maker/SKILL.md",
"content": "---\nname: slide-maker\ndescription: Create HTML slide decks\n---\n# Slide Maker\n\nWhen asked to create a presentation:\n1. Analyze the input data\n2. Create an HTML slide deck with reveal.js\n3. Save to /workspace/output/slides.html"
}
]
}
}'
As skills carregadas do .agents/skills/ e do /.agents/skills/ são descobertas automaticamente.
Criar um agente gerenciado
Depois de iterar na configuração, é possível criá-la como um agente gerenciado com agents.create. Isso permite invocar o agente por ID sem repetir a configuração todas as vezes.
De fontes
Especifique base_agent, id, system_instruction e base_environment com fontes. A plataforma provisiona um novo sandbox com seus arquivos em cada invocação. Consulte Ambientes para ver os tipos de origem disponíveis (Git, GCS, inline).
Python
from google import genai
client = genai.Client()
agent = client.agents.create(
id="data-analyst",
base_agent="antigravity-preview-05-2026",
system_instruction="You are a data analyst. Always include visualizations and export results as PDF.",
base_environment={
"type": "remote",
"sources": [
{
"type": "inline",
"target": ".agents/AGENTS.md",
"content": "Always use matplotlib for charts. Include a summary table in every report.",
},
{
"type": "inline",
"target": ".agents/skills/slide-maker/SKILL.md",
"content": "---\nname: slide-maker\n---\n# Slide Maker\nCreate HTML slide decks from data analysis results.",
},
{
"type": "repository",
"source": "https://github.com/my-org/analysis-templates",
"target": "/workspace/templates",
},
],
},
)
print(f"Created agent: {agent.id}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const agent = await client.agents.create({
id: "data-analyst",
base_agent: "antigravity-preview-05-2026",
system_instruction: "You are a data analyst. Always include visualizations and export results as PDF.",
base_environment: {
type: "remote",
sources: [
{
type: "inline",
target: ".agents/AGENTS.md",
content: "Always use matplotlib for charts. Include a summary table in every report.",
},
{
type: "inline",
target: ".agents/skills/slide-maker/SKILL.md",
content: "---\nname: slide-maker\n---\n# Slide Maker\nCreate HTML slide decks from data analysis results.",
},
{
type: "repository",
source: "https://github.com/my-org/analysis-templates",
target: "/workspace/templates",
},
],
},
});
console.log(`Created agent: ${agent.id}`);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/agents" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"id": "data-analyst",
"base_agent": "antigravity-preview-05-2026",
"system_instruction": "You are a data analyst. Always include visualizations and export results as PDF.",
"base_environment": {
"type": "remote",
"sources": [
{
"type": "inline",
"target": ".agents/AGENTS.md",
"content": "Always use matplotlib for charts. Include a summary table in every report."
},
{
"type": "inline",
"target": ".agents/skills/slide-maker/SKILL.md",
"content": "---\nname: slide-maker\n---\n# Slide Maker\nCreate HTML slide decks from data analysis results."
},
{
"type": "repository",
"source": "https://github.com/my-org/analysis-templates",
"target": "/workspace/templates"
}
]
}
}'
De um ambiente atual (fork)
Itere com o agente base do Antigravity até que o ambiente esteja correto (pacotes instalados, arquivos no lugar) e crie um fork dele em um agente gerenciado.
Python
from google import genai
client = genai.Client()
# Step 1: set up the environment interactively
interaction = client.interactions.create(
agent="antigravity-preview-05-2026",
input="Install pandas, matplotlib, and seaborn. Create an analysis template at /workspace/template.py.",
environment="remote",
)
# Step 2: fork that environment into a managed agent
agent = client.agents.create(
id="my-data-analyst",
base_agent="antigravity-preview-05-2026",
system_instruction="You are a data analyst. Use the template at /workspace/template.py for all reports.",
base_environment=interaction.environment_id,
)
print(f"Forked agent successfully: {agent.id}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({
agent: "antigravity-preview-05-2026",
input: "Install pandas, matplotlib, and seaborn. Create an analysis template at /workspace/template.py.",
environment: "remote",
}, { timeout: 300000 });
const agent = await client.agents.create({
id: "my-data-analyst",
base_agent: "antigravity-preview-05-2026",
system_instruction: "You are a data analyst. Use the template at /workspace/template.py for all reports.",
base_environment: interaction.environment_id,
});
console.log(`Forked agent successfully: ${agent.id}`);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Install pandas, matplotlib, and seaborn. Create an analysis template at /workspace/template.py.",
"environment": "remote"
}'
Com regras de rede
É possível bloquear o acesso de saída ou injetar credenciais ao salvar um agente gerenciado. Para conferir o esquema completo da lista de permissões, os padrões de credenciais e os caracteres curinga, consulte Ambientes: configuração de rede.
O exemplo a seguir cria um agente issue-resolver que só pode acessar o GitHub e o PyPI, com credenciais injetadas para o GitHub:
Python
from google import genai
client = genai.Client()
agent = client.agents.create(
id="issue-resolver",
base_agent="antigravity-preview-05-2026",
system_instruction="You resolve GitHub issues. Clone the repo, find the bug, write the fix, run the tests, and open a PR.",
base_environment={
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/my-org/backend",
"target": "/workspace/repo",
}
],
"network": {
"allowlist": [
{
"domain": "api.github.com",
"transform": {
"Authorization": "Basic YOUR_BASE64_TOKEN"
},
},
{"domain": "pypi.org"},
]
},
},
)
print(f"Created issue-resolver agent successfully: {agent.id}")
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const agent = await client.agents.create({
id: "issue-resolver",
base_agent: "antigravity-preview-05-2026",
system_instruction: "You resolve GitHub issues. Clone the repo, find the bug, write the fix, run the tests, and open a PR.",
base_environment: {
type: "remote",
sources: [
{
type: "repository",
source: "https://github.com/my-org/backend",
target: "/workspace/repo",
}
],
network: {
allowlist: [
{
domain: "api.github.com",
transform: {
"Authorization": "Basic YOUR_BASE64_TOKEN"
},
},
{ domain: "pypi.org" },
]
}
},
});
console.log(`Created issue-resolver agent successfully: ${agent.id}`);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/agents" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"id": "issue-resolver",
"base_agent": "antigravity-preview-05-2026",
"system_instruction": "You resolve GitHub issues. Clone the repo, find the bug, write the fix, run the tests, and open a PR.",
"base_environment": {
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/my-org/backend",
"target": "/workspace/repo"
}
],
"network": {
"allowlist": [
{
"domain": "api.github.com",
"transform": {
"Authorization": "Basic YOUR_BASE64_TOKEN"
}
},
{"domain": "pypi.org"}
]
}
}
}'
Invocar o agente
Chame seu agente gerenciado com o ID dele criando uma nova interação. Cada invocação ramifica o ambiente de base, então cada execução começa do zero.
Python
result = client.interactions.create(
agent="data-analyst",
input="Analyze Q1 revenue data from /workspace/templates/sample.csv and create a slide deck.",
environment="remote",
)
print(result.output_text)
JavaScript
const result = await client.interactions.create({
agent: "data-analyst",
input: "Analyze Q1 revenue data from /workspace/templates/sample.csv and create a slide deck.",
environment: "remote",
}, { timeout: 300000 });
console.log(result.output_text);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "data-analyst",
"input": "Analyze Q1 revenue data from /workspace/templates/sample.csv and create a slide deck.",
"environment": "remote"
}'
Para conversas em várias etapas e streaming, consulte o guia de início rápido. Os mesmos padrões previous_interaction_id e environment se aplicam a agentes gerenciados.
Os agentes gerenciados também são compatíveis com execução e cancelamento em segundo plano. Para detalhes e exemplos de código, consulte Agente antigravidade: execução em segundo plano.
Como modificar a configuração na invocação
É possível substituir a configuração de rede padrão system_instruction, tools e environment do agente ao criar uma interação. Isso permite modificar o comportamento, as capacidades ou as credenciais do agente para uma execução específica sem mudar a definição armazenada do agente.
Substituir instruções e ferramentas do sistema
Python
result = client.interactions.create(
agent="data-analyst",
input="Analyze Q1 revenue data, but do not create a slide deck. Just output a summary table.",
system_instruction="You are a data analyst. Focus ONLY on summary tables. Ignore default instructions about slides.",
tools=[{"type": "code_execution"}], # Override to only use code execution
environment="remote",
)
print(result.output_text)
JavaScript
const result = await client.interactions.create({
agent: "data-analyst",
input: "Analyze Q1 revenue data, but do not create a slide deck. Just output a summary table.",
system_instruction: "You are a data analyst. Focus ONLY on summary tables. Ignore default instructions about slides.",
tools: [{ type: "code_execution" }], // Override to only use code execution
environment: "remote",
}, { timeout: 300000 });
console.log(result.output_text);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "data-analyst",
"input": "Analyze Q1 revenue data, but do not create a slide deck. Just output a summary table.",
"system_instruction": "You are a data analyst. Focus ONLY on summary tables. Ignore default instructions about slides.",
"tools": [{"type": "code_execution"}],
"environment": "remote"
}'
Substituir a configuração de rede (atualizar credenciais)
Se o agente gerenciado tiver credenciais de rede incorporadas ao base_environment,
será possível substituir essas credenciais no momento da invocação para atualizar tokens expirados ou alternar chaves de
API. Transmita um objeto environment com uma nova configuração network. As novas regras de rede substituem totalmente as anteriores para essa interação. As fontes do ambiente
de base (arquivos, repositórios) são preservadas.
Python
# Invoke the agent with a fresh token, overriding the base_environment credentials
result = client.interactions.create(
agent="issue-resolver",
input="Fix issue #42 and open a PR.",
environment={
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"transform": {
"Authorization": "Bearer ghp_REFRESHED_TOKEN"
},
},
{"domain": "pypi.org"},
]
},
},
)
print(result.output_text)
JavaScript
// Invoke the agent with a fresh token, overriding the base_environment credentials
const result = await client.interactions.create({
agent: "issue-resolver",
input: "Fix issue #42 and open a PR.",
environment: {
type: "remote",
network: {
allowlist: [
{
domain: "api.github.com",
transform: {
"Authorization": "Bearer ghp_REFRESHED_TOKEN"
},
},
{ domain: "pypi.org" },
]
},
},
}, { timeout: 300000 });
console.log(result.output_text);
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"agent": "issue-resolver",
"input": "Fix issue #42 and open a PR.",
"environment": {
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"transform": {
"Authorization": "Bearer ghp_REFRESHED_TOKEN"
}
},
{"domain": "pypi.org"}
]
}
}
}'
Gerenciar agentes
É possível listar, receber e excluir agentes.
Listar agentes
Python
agents = client.agents.list()
for a in agents.agents:
print(f"{a.id}: {a.description}")
JavaScript
const agents = await client.agents.list();
if (agents.agents) {
for (const a of agents.agents) {
console.log(`${a.id}: ${a.description}`);
}
}
REST
curl -X GET "https://generativelanguage.googleapis.com/v1beta/agents" \
-H "x-goog-api-key: $GEMINI_API_KEY"
Obter um agente
Python
agent = client.agents.get(id="data-analyst")
print(agent)
JavaScript
const agent = await client.agents.get("data-analyst");
console.log(agent);
REST
curl -X GET "https://generativelanguage.googleapis.com/v1beta/agents/data-analyst" \
-H "x-goog-api-key: $GEMINI_API_KEY"
Excluir um agente
A exclusão remove a configuração. Os ambientes e as interações criados pelo agente não são afetados.
Python
client.agents.delete(id="data-analyst")
JavaScript
await client.agents.delete("data-analyst");
REST
curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/agents/data-analyst" \
-H "x-goog-api-key: $GEMINI_API_KEY"
Referência de definição do agente
| Campo | Tipo | Obrigatório | Descrição |
|---|---|---|---|
id |
string | Sim | Identificador exclusivo do agente. Usado para invocar o agente. |
description |
string | Não | Descrição do agente legível por humanos. |
base_agent |
string | Sim | ID do agente de base (por exemplo, antigravity-preview-05-2026). |
system_instruction |
string | Não | Comando do sistema que define o comportamento e o perfil. |
tools |
matriz | Não | Ferramentas que o agente pode usar. Se omitido, o padrão será code_execution, google_search e url_context. As ferramentas compatíveis incluem code_execution, google_search, url_context, mcp_server e definições personalizadas de function. |
base_environment |
string ou objeto | Não | "remote", um environment_id ou um objeto de configuração com sources e network. Consulte "Ambientes". |
Fluxo de trabalho de iteração
- Prototipar com o agente base do Antigravity. Transmita instruções do sistema e fontes de ambiente inline. Testar instruções, habilidades e configuração do ambiente de forma interativa.
- Estabilize o ambiente. Instale pacotes, monte fontes e verifique se tudo funciona.
- Persista como um agente gerenciado criando um novo agente, seja de fontes ou bifurcando o ambiente.
- Atualize a definição do agente. Mude a instrução do sistema, troque habilidades ou adicione fontes. A próxima invocação vai usar a nova configuração.
Limitações
- Status da prévia: os agentes gerenciados estão em prévia. Os recursos e esquemas podem mudar.
- Agente de base: somente
antigravity-preview-05-2026é aceito comobase_agent. - Sem controle de versões: o controle de versões e o rollback do agente ainda não estão disponíveis.
- Sem aninhamento de subagentes: a delegação de subagentes ainda não é compatível.
- É possível ter até 1.000 agentes gerenciados.
A seguir
- Visão geral dos agentes: conheça os conceitos principais dos agentes gerenciados.
- Guia de início rápido: comece a criar com conversas multiturno e streaming.
- Agente antigravidade: conheça os recursos, as ferramentas e os preços do agente padrão.
- Ambientes de agente: configure sandboxes, fontes e redes.
- API Managed Agents na Agent Platform: para criar agentes com governança organizacional integrada.