Zarządzani agenci w interfejsie Gemini API umożliwiają rozszerzenie agenta Antigravity o własne instrukcje, umiejętności i dane. Możesz dostosować agenta w trakcie interakcji lub zapisać konfigurację jako zarządzanego agenta, którego wywołujesz za pomocą identyfikatora.
Dostosowywanie agenta Antigravity
Najszybszym sposobem na utworzenie niestandardowego agenta jest przekazanie konfiguracji w wierszu podczas tworzenia nowej interakcji bez konieczności rejestracji. Agenta możesz rozszerzyć na 3 sposoby:
- Instrukcje systemowe: przekazuj tekst wbudowany za pomocą
system_instruction, aby kształtować zachowanie. - Narzędzia: zastąp domyślne narzędzia (wykonywanie kodu, wyszukiwanie, kontekst adresu URL).
- Pliki i umiejętności: zamontuj w środowisku pliki takie jak
AGENTS.mdiSKILL.md.
Oto przykład przekazywania wszystkich 3 parametrów w formie wbudowanej:
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."
}
]
}
}'
Wszystko jest definiowane w momencie interakcji. Nie musisz niczego rejestrować. Platforma agenta Antigravity zapewnia środowisko wykonawcze (wykonywanie kodu, zarządzanie plikami, dostęp do internetu), a Ty możesz na niej umieścić warstwy konfiguracji.
Narzędzia i instrukcje systemowe
Możesz dostosować zachowanie i możliwości agenta w przypadku konkretnej interakcji za pomocą parametrów system_instruction i tools.
- Instrukcje systemowe: użyj parametru
system_instruction, aby przekazać tekst wbudowany, który kształtuje zachowanie agenta. To idealne rozwiązanie do szybkich zmian, które chcesz wprowadzać w przypadku poszczególnych połączeń.system_instructioniAGENTS.mdsię sumują. Oba obowiązują, gdy są obecne. - Narzędzia: domyślnie agent Antigravity ma dostęp do tych narzędzi:
code_execution,google_searchiurl_context. Możesz zastąpić tę listę, przekazując parametrtoolsw momencie interakcji. Szczegółowe informacje o dostępnych narzędziach i sposobie ich używania znajdziesz w artykule Antigravity Agent: obsługiwane narzędzia.
Dostosowywanie na podstawie plików
Struktura katalogu agenta
Konfigurację można przekazywać w wierszu, ale zalecamy uporządkowanie plików agenta w strukturalnym katalogu. Ułatwia to zarządzanie, kontrolowanie wersji i montowanie w środowisku agenta.
Typowy katalog projektu agenta wygląda tak:
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
Środowisko wykonawcze Antigravity skanuje .agents/ (i katalog główny środowiska) pod kątem tych plików.
AGENTS.md
Agent automatycznie wczytuje .agents/AGENTS.md (lub /.agents/AGENTS.md) ze środowiska jako instrukcje systemowe podczas uruchamiania. Używaj AGENTS.md w przypadku długich definicji person, szczegółowych wytycznych i instrukcji, które chcesz kontrolować pod kątem wersji razem z kodem.
Zamontuj AGENTS.md za pomocą źródła wbudowanego:
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."
}
]
}
}'
Umiejętności: SKILL.md
Umiejętności to pliki, które rozszerzają możliwości agenta. Umieść je pod .agents/skills/<skill-name>/SKILL.md, a wiązka automatycznie je wykryje i zarejestruje.
.agents/
├── AGENTS.md
└── skills/
└── slide-maker/
└── SKILL.md
Zainstaluj umiejętność za pomocą źródła wbudowanego:
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"
}
]
}
}'
Umiejętności załadowane z usług .agents/skills/ i /.agents/skills/ są wykrywane automatycznie.
Tworzenie zarządzanego agenta
Po wprowadzeniu zmian w konfiguracji możesz utworzyć z niej zarządzanego agenta za pomocą agents.create. Dzięki temu możesz wywoływać agenta za pomocą identyfikatora bez konieczności powtarzania konfiguracji za każdym razem.
Ze źródeł
Podaj base_agent, id, system_instruction i base_environment wraz ze źródłami. Przy każdym wywołaniu platforma udostępnia nowe środowisko testowe z Twoimi plikami. Dostępne typy źródeł (Git, GCS, wbudowane) znajdziesz w sekcji Środowiska.
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"
}
]
}
}'
Z istniejącego środowiska (fork)
Powtarzaj działania z podstawowym agentem Antigravity, aż środowisko będzie odpowiednie (zainstalowane pakiety, pliki na miejscu), a następnie utwórz z niego rozwidlenie w postaci zarządzanego agenta.
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"
}'
Z regułami sieciowymi
Podczas zapisywania zarządzanego agenta możesz zablokować dostęp wychodzący lub wstawić dane logowania. Pełny schemat listy dozwolonych, wzorce danych logowania i symbole wieloznaczne znajdziesz w sekcji Środowiska: konfiguracja sieci.
W tym przykładzie tworzymy agenta issue-resolver, który ma dostęp tylko do GitHuba i PyPI, a dane logowania do GitHuba są wstrzykiwane:
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"}
]
}
}
}'
Wywołaj agenta
Zadzwoń do zarządzanego agenta, podając identyfikator agenta, tworząc nową interakcję. Każde wywołanie rozwidla środowisko bazowe, więc każde uruchomienie zaczyna się od czystego stanu.
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"
}'
Więcej informacji o rozmowach wieloetapowych i przesyłaniu strumieniowym znajdziesz w krótkim wprowadzeniu. Te same wzorce previous_interaction_id i environment dotyczą zarządzanych agentów.
Zastępowanie konfiguracji podczas wywołania
Podczas tworzenia interakcji możesz zastąpić domyślne wartości system_instruction i tools agenta. Dzięki temu możesz zmodyfikować zachowanie lub możliwości agenta w przypadku konkretnego uruchomienia bez zmiany zapisanej definicji agenta.
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"
}'
Zarządzaj agentami
Możesz wyświetlać, pobierać i usuwać agentów.
Wyświetlenie listy agentów
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"
Uzyskiwanie dostępu do agenta
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"
Usuwanie agenta
Usunięcie powoduje usunięcie konfiguracji. Nie ma to wpływu na istniejące środowiska i interakcje utworzone przez agenta.
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"
Dokumentacja definicji agenta
| Pole | Typ | Wymagane | Opis |
|---|---|---|---|
id |
ciąg znaków | Tak | Unikalny identyfikator agenta. Służy do wywoływania agenta. |
description |
ciąg znaków | Nie | Zrozumiały dla człowieka opis agenta. |
base_agent |
ciąg znaków | Tak | Identyfikator agenta podstawowego (np. antigravity-preview-05-2026). |
system_instruction |
ciąg znaków | Nie | Prompt systemowy określający zachowanie i osobowość. |
tools |
ciąg znaków lub obiekt. | Nie | Narzędzia, których agent może używać. Jeśli to pole zostanie pominięte, agent będzie mieć dostęp do narzędzi code_execution, google_search i url_context. |
base_environment |
ciąg znaków lub obiekt. | Nie | "remote", environment_id lub obiekt konfiguracji z wartościami sources i network. Zobacz Środowiska. |
Przepływ pracy iteracji
- Prototypuj za pomocą podstawowego agenta Antigravity. Przekazywanie instrukcji systemowych i źródeł środowiska w formie wbudowanej. Interaktywne testowanie instrukcji, umiejętności i konfiguracji środowiska.
- Ustabilizuj środowisko. Zainstaluj pakiety, zamontuj źródła i sprawdź, czy wszystko działa.
- Utrwal agenta zarządzanego, tworząc nowego agenta ze źródeł lub przez rozwidlenie środowiska.
- Zaktualizuj definicję agenta. zmieniać instrukcje systemowe, zamieniać umiejętności lub dodawać źródła; Następne wywołanie będzie już korzystać z nowej konfiguracji.
Ograniczenia
- Stan podglądu: zarządzani agenci są w wersji podglądowej. Funkcje i schematy mogą ulec zmianie.
- Agent podstawowy: jako
base_agentobsługiwana jest tylko wartośćantigravity-preview-05-2026. - Brak obsługi wersji: obsługa wersji agenta i przywracanie nie są jeszcze dostępne.
- Brak zagnieżdżania subagentów: delegowanie subagentów nie jest jeszcze obsługiwane.
- Możesz mieć maksymalnie 1000 zarządzanych agentów.
Co dalej?
- Omówienie agentów: poznaj podstawowe koncepcje związane z agentami zarządzanymi.
- Krótkie wprowadzenie: zacznij tworzyć aplikacje z wielokrotnymi rozmowami i strumieniowaniem.
- Antigravity Agent: poznaj możliwości, narzędzia i cennik domyślnego agenta.
- Środowiska agenta: konfigurowanie piaskownic, źródeł i sieci.