Verwaltete Agents erstellen

Mit verwalteten Agents in der Gemini API können Sie den Antigravity-Agent mit eigenen Anweisungen, Skills 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 verschiedene Arten erweitern:

  • Modellauswahl: Wählen Sie das zugrunde liegende Gemini-Modell über agent_config aus. Standardmäßig ist Gemini 3.8 Flash ausgewählt.
  • Systemanweisungen: Übergeben Sie Inline-Text über system_instruction, um das Verhalten zu beeinflussen.
  • Tools: Überschreiben Sie Standardtools (Codeausführung, Suche, URL-Kontext), registrieren Sie Remote-MCP-Server oder definieren Sie benutzerdefinierte Funktionen (Funktionsaufruf).
  • Dateien und Skills: Binden Sie Dateien wie AGENTS.md und SKILL.md in die Umgebung ein.

Hier ein Beispiel für die Inline-Übergabe aller drei:

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);

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;

Client client = new Client();

CreateAgentInteraction params =
    CreateAgentInteraction.builder()
        .agent(AgentOption.of("antigravity-preview-05-2026"))
        .input(InteractionsInput.of("Build a simple REST API server in Node.js."))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println(interaction.outputText().orElse(""));

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."
            }
        ]
    }
}'

Alles wird während der Interaktion definiert. Sie müssen nichts im Voraus registrieren. Das Antigravity-Agent-Framework bietet die Laufzeit (Code-Ausfü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_instruction und AGENTS.md sind additiv. Beide werden angewendet, wenn sie vorhanden sind.
  • Tools: Standardmäßig hat der Antigravity-Agent Zugriff auf code_execution, google_search, und url_context. Sie können diese Liste überschreiben, indem Sie den Parameter tools während der Interaktion übergeben. Sie können auch Remote-MCP-Server registrieren oder benutzerdefinierte Funktionen (Funktionsaufruf) definieren, um den Agent mit Ihren eigenen APIs und Datenbanken zu verbinden. Ausführliche Informationen zu den verfügbaren Tools finden Sie unter Antigravity-Agent: Unterstützte Tools.

Dateibasierte Anpassung

Verzeichnisstruktur des Agent

Sie können zwar die Konfiguration 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 versionieren 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);

Java

import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;

Client client = new Client();

CreateAgentInteraction params =
    CreateAgentInteraction.builder()
        .agent(AgentOption.of("antigravity-preview-05-2026"))
        .input(InteractionsInput.of("Build a simple REST API server in Node.js."))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println(interaction.outputText().orElse(""));

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."
              }
          ]
      }
  }'

Skills: SKILL.md

Skills sind Dateien, die die Fähigkeiten des Agent erweitern. Platzieren Sie sie unter .agents/skills/<skill-name>/SKILL.md. Die Harness erkennt und registriert sie automatisch.

.agents/
├── AGENTS.md
└── skills/
    └── slide-maker/
        └── SKILL.md

So binden Sie einen Skill ü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"