Mit verwalteten Agents in der Gemini API können Sie den Antigravity-Agent mit eigenen Anweisungen, Fähigkeiten und Daten erweitern. Sie können den Agent während der Interaktion direkt anpassen oder die Konfiguration als verwalteten Agent speichern, den Sie per ID aufrufen.
Antigravity-Agent anpassen
Die schnellste Möglichkeit, einen benutzerdefinierten Agent zu erstellen, besteht darin, die Konfiguration direkt zu übergeben, während Sie eine neue Interaktion erstellen. Ein Registrierungsschritt ist nicht erforderlich. Sie können den Agent auf drei Arten erweitern:
- Systemanweisungen: Übergeben Sie Inline-Text über
system_instruction, um das Verhalten zu beeinflussen. - Tools: Überschreiben Sie die Standardtools (Codeausführung, Suche, URL-Kontext).
- Dateien und Fähigkeiten: Binden Sie Dateien wie
AGENTS.mdundSKILL.mdin die Umgebung ein.
Hier ein Beispiel für die Übergabe aller drei Inline-Elemente:
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" \
-H "Api-Revision: 2026-05-20" \
-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."
}
]
}
}'
Alles wird während der Interaktion definiert. Sie müssen nichts im Voraus registrieren. Das Antigravity-Agent-Framework bietet die Laufzeitumgebung (Codeausführung, Dateiverwaltung, Webzugriff) und Ihre Konfigurationsebenen.
Tools und Systemanweisungen
Sie können das Verhalten und die Fähigkeiten des Agent für eine bestimmte Interaktion mit den Parametern system_instruction und tools anpassen.
- Systemanweisungen: Verwenden Sie den Parameter
system_instruction, um Inline-Text zu übergeben, der das Verhalten des Agent beeinflusst. Dies ist ideal für schnelle Anpassungen, die Sie pro Aufruf ändern möchten.system_instructionundAGENTS.mdsind additiv. Beide werden angewendet, wenn sie vorhanden sind. - Tools: Standardmäßig hat der Antigravity-Agent Zugriff auf
code_execution,google_search, undurl_context. Sie können diese Liste überschreiben, indem Sie den Parametertoolswährend der Interaktion übergeben. Ausführliche Informationen zu den verfügbaren Tools und ihrer Verwendung finden Sie unter Antigravity-Agent: Unterstützte Tools.
Dateibasierte Anpassung
Verzeichnisstruktur des Agent
Sie können die Konfiguration zwar direkt übergeben, wir empfehlen jedoch, die Dateien des Agent in einem strukturierten Verzeichnis zu organisieren. So lassen sie sich einfacher verwalten, versionieren und in die Umgebung des Agent einbinden.
Ein typisches Agent-Projektverzeichnis sieht so aus:
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
Die Antigravity-Laufzeitumgebung sucht in .agents/ (und im Stammverzeichnis der Umgebung) nach diesen Dateien.
AGENTS.md
Der Agent lädt beim Start automatisch .agents/AGENTS.md (oder /.agents/AGENTS.md) aus der Umgebung als Systemanweisungen. Verwenden Sie AGENTS.md für ausführliche Personadefinitionen, detaillierte Richtlinien und Anweisungen, die Sie zusammen mit Ihrem Code in der Versionsverwaltung speichern möchten.
So binden Sie eine AGENTS.md-Datei über eine Inline-Quelle ein:
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" \
-H "Api-Revision: 2026-05-20" \
-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."
}
]
}
}'
Fähigkeiten: SKILL.md
Fähigkeiten sind Dateien, die die Fähigkeiten des Agent erweitern. Platzieren Sie sie unter .agents/skills/<skill-name>/SKILL.md. Das Framework erkennt und registriert sie automatisch.
.agents/
├── AGENTS.md
└── skills/
└── slide-maker/
└── SKILL.md
So binden Sie eine Fähigkeit über eine Inline-Quelle ein:
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" \
-H "Api-Revision: 2026-05-20" \
-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"
}
]
}
}'
Fähigkeiten, die aus .agents/skills/ und /.agents/skills/ geladen werden, werden automatisch erkannt.
Verwalteten Agent erstellen
Sobald Sie Ihre Konfiguration durchlaufen haben, können Sie sie mit agents.create als verwalteten Agent erstellen. So können Sie den Agent per ID aufrufen, ohne die Konfiguration jedes Mal zu wiederholen.
Aus Quellen
Geben Sie base_agent, id, system_instruction und base_environment mit Quellen an. Die Plattform stellt bei jedem Aufruf eine neue Sandbox mit Ihren Dateien bereit. Unter Umgebungen finden Sie die verfügbaren Quelltypen (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" \
-H "Api-Revision: 2026-05-20" \
-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"
}
]
}
}'
Aus einer vorhandenen Umgebung (Fork)
Durchlaufen Sie den Antigravity-Basis-Agent, bis die Umgebung richtig ist (Pakete installiert, Dateien vorhanden), und forken Sie ihn dann in einen verwalteten Agent.
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" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "antigravity-preview-05-2026",
"input": "Install pandas, matplotlib, and seaborn. Create an analysis template at /workspace/template.py.",
"environment": "remote"
}'
Mit Netzwerkregeln
Sie können den ausgehenden Zugriff einschränken oder Anmeldedaten einfügen, wenn Sie einen verwalteten Agent speichern. Das vollständige Schema für die Zulassungsliste, Anmeldedatenmuster und Platzhalter finden Sie unter Umgebungen: Netzwerkkonfiguration.
Im folgenden Beispiel wird ein issue-resolver-Agent erstellt, der nur auf GitHub und PyPI zugreifen kann. Für GitHub werden Anmeldedaten eingefügt:
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" \
-H "Api-Revision: 2026-05-20" \
-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"}
]
}
}
}'
Agent aufrufen
Rufen Sie Ihren verwalteten Agent mit Ihrer Agent-ID auf, indem Sie eine neue Interaktion erstellen. Bei jedem Aufruf wird die Basisumgebung geforkt, sodass jeder Lauf sauber beginnt.
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" \
-H "Api-Revision: 2026-05-20" \
-d '{
"agent": "data-analyst",
"input": "Analyze Q1 revenue data from /workspace/templates/sample.csv and create a slide deck.",
"environment": "remote"
}'
Informationen zu Unterhaltungen mit mehreren Runden und Streaming finden Sie in der Kurzanleitung. Dieselben previous_interaction_id- und environment-Muster gelten für verwaltete Agents.
Konfiguration beim Aufruf überschreiben
Sie können die Standardwerte für system_instruction und tools des Agent überschreiben, wenn Sie eine Interaktion erstellen. So können Sie das Verhalten oder die Fähigkeiten des Agent für einen bestimmten Lauf ändern, ohne die gespeicherte Agent-Definition zu ändern.
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" \
-H "Api-Revision: 2026-05-20" \
-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"
}'
KI-Agenten verwalten
Sie können Agents auflisten, abrufen und löschen.
Agents auflisten
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"
KI-Agenten abrufen
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"
KI-Agent löschen
Durch das Löschen wird die Konfiguration entfernt. Vorhandene Umgebungen und Interaktionen, die vom Agent erstellt wurden, sind davon nicht betroffen.
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"
Referenz zur Agent-Definition
| Feld | Typ | Erforderlich | Beschreibung |
|---|---|---|---|
id |
String | Ja | Eindeutige Agent-ID. Wird zum Aufrufen des Agent verwendet. |
description |
String | Nein | Eine menschenlesbare Beschreibung des KI-Agenten. |
base_agent |
String | Ja | Basis-Agent-ID (z.B. antigravity-preview-05-2026). |
system_instruction |
String | Nein | Systemanweisung, die Verhalten und Persona definiert. |
tools |
String oder Objekt | Nein | Tools, die der Agent verwenden kann. Wenn dieser Parameter weggelassen wird, hat der Agent Zugriff auf code_execution, google_search und url_context. |
base_environment |
String oder Objekt | Nein | "remote", eine environment_id oder ein Konfigurationsobjekt mit sources und network. Siehe Umgebungen. |
Workflow für die Iteration
- Prototyp mit dem Antigravity-Basis-Agent. Übergeben Sie Systemanweisungen und Umgebungsquellen direkt. Testen Sie Anweisungen, Fähigkeiten und die Umgebungskonfiguration interaktiv.
- Stabilisieren Sie die Umgebung. Installieren Sie Pakete, binden Sie Quellen ein und prüfen Sie, ob alles funktioniert.
- Speichern Sie die Konfiguration als verwalteten Agent, indem Sie entweder einen neuen Agent aus Quellen erstellen oder die Umgebung forken.
- Aktualisieren Sie die Agent-Definition. Ändern Sie die Systemanweisung, tauschen Sie Fähigkeiten aus oder fügen Sie Quellen hinzu. Beim nächsten Aufruf wird die neue Konfiguration verwendet.
Beschränkungen
- Vorschau: Verwaltete Agents sind in der Vorschau. Funktionen und Schemas können sich ändern.
- Basis-Agent: Nur
antigravity-preview-05-2026wird alsbase_agentunterstützt. - Keine Versionierung: Die Agent-Versionsverwaltung und das Rollback sind noch nicht verfügbar.
- Keine Verschachtelung von Unter-Agents: Die Delegierung von Unter-Agents wird noch nicht unterstützt.
- Sie können bis zu 1.000 verwaltete Agents haben.
Nächste Schritte
- Übersicht über Agents: Informationen zu den grundlegenden Konzepten verwalteter Agents.
- Kurzanleitung: Erstellen Sie Agents mit Unterhaltungen mit mehreren Runden und Streaming.
- Antigravity-Agent: Informationen zu Funktionen, Tools und Preisen für den Standard-Agent.
- Agent-Umgebungen: Konfigurieren Sie Sandboxes, Quellen und Netzwerke.