סוכנים מנוהלים ב-Gemini API מאפשרים לכם להרחיב את סוכן Antigravity באמצעות הוראות, מיומנויות ונתונים משלכם. אתם יכולים להתאים אישית את הסוכן בתוך השיחה במועד האינטראקציה, או לשמור את ההגדרה כסוכן מנוהל שמופעל באמצעות מזהה.
התאמה אישית של סוכן Antigravity
הדרך המהירה ביותר לבנות סוכן בהתאמה אישית היא להעביר את ההגדרה שלכם בשורה בזמן יצירת אינטראקציה חדשה, בלי שנדרש שלב הרשמה. יש כמה דרכים מרכזיות להרחיב את הסוכן:
- בחירת מודל: אפשר לבחור את מודל Gemini הבסיסי באמצעות
agent_config(ברירת המחדל היא Gemini 3.8 Flash). - הוראות מערכת: העברת טקסט מוטבע באמצעות
system_instructionלעיצוב התנהגות. - כלים: אפשר לבטל את ברירת המחדל של הכלים (הפעלת קוד, חיפוש, הקשר של כתובת URL), לרשום שרתי MCP מרוחקים או להגדיר פונקציות בהתאמה אישית (הפעלת פונקציות).
- קבצים וסקילים: העלאת קבצים כמו
AGENTS.mdו-SKILL.mdלסביבה.
דוגמה להעברת כל שלושת הפרמטרים בתוך התג:
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."
}
]
}
}'
הכול מוגדר במועד האינטראקציה. אין צורך לרשום משהו קודם. ה-Antigravity agent harness מספק את זמן הריצה (הרצת קוד, ניהול קבצים, גישה לאינטרנט) ואת שכבות ההגדרה שלכם מעל.
כלים והוראות למערכת
אתם יכולים להתאים אישית את ההתנהגות והיכולות של סוכן המכירות הווירטואלי לאינטראקציה ספציפית באמצעות הפרמטרים system_instruction ו-tools.
- הוראות למערכת: משתמשים בפרמטר
system_instructionכדי להעביר טקסט מוטבע שמשפיע על התנהגות הסוכן. האפשרות הזו מתאימה לשינויים קלים שרוצים לבצע בכל שיחה.system_instructionו-AGENTS.mdהם מאפיינים מצטברים, שניהם חלים אם הם קיימים. - כלים: כברירת מחדל, לסוכן Antigravity יש גישה אל
code_execution,google_searchו-url_context. אפשר לשנות את הרשימה הזו על ידי העברת הפרמטרtoolsבמועד האינטראקציה. אפשר גם לרשום שרתי MCP מרוחקים או להגדיר פונקציות בהתאמה אישית (הפעלת פונקציות) כדי לחבר את הסוכן לממשקי ה-API ולמסדי הנתונים שלכם. פרטים מלאים על הכלים הזמינים מופיעים במאמר Antigravity Agent: Supported tools.
התאמה אישית מבוססת-קובץ
מבנה ספריית הסוכנים
אפשר להעביר את ההגדרה בשורה, אבל מומלץ לארגן את הקבצים של הסוכן בספרייה מובנית. כך קל יותר לנהל את הקבצים, לשלוט בגרסאות שלהם ולטעון אותם בסביבת הסוכן.
ספריית פרויקט טיפוסית של סוכן נראית כך:
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
זמן הריצה של Antigravity סורק את .agents/ (ואת שורש הסביבה) כדי למצוא את הקבצים האלה.
AGENTS.md
הסוכן טוען אוטומטית את .agents/AGENTS.md (או /.agents/AGENTS.md) מהסביבה כהוראות מערכת בזמן ההפעלה. מומלץ להשתמש ב-AGENTS.md להגדרות ארוכות של פרסונות, להנחיות מפורטות ולהוראות שרוצים לשמור בניהול גרסאות לצד הקוד.
הוספת AGENTS.md באמצעות מקור מוטבע:
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."
}
]
}
}'
מיומנויות: SKILL.md
מיומנויות הן קבצים שמרחיבים את היכולות של הסוכן. ממקמים אותם מתחת ל-.agents/skills/<skill-name>/SKILL.md והרצועה מזהה ורושמת אותם באופן אוטומטי.
.agents/
├── AGENTS.md
└── skills/
└── slide-maker/
└── SKILL.md
הוספת סקיל באמצעות מקור מוטבע:
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);
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": "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"
}
]
}
}'
ה-Skills שנטענו מ-.agents/skills/ ומ-/.agents/skills/ מתגלים באופן אוטומטי.
יצירת סוכן מנוהל
אחרי שמשפרים את ההגדרה, אפשר ליצור אותה כסוכן מנוהל באמצעות agents.create. כך אפשר להפעיל את הסוכן לפי מזהה בלי לחזור על ההגדרה בכל פעם.
המזהה id שאתם מציינים כשיוצרים סוכן מנוהל צריך להיות ייחודי לפרויקט, ואסור שהוא יתחיל בקידומות שמורות (למשל, google-, gemini-). כאן אפשר לראות את הרשימה המלאה של הקידומות המוגבלות.
ממקורות
מציינים את base_agent, id, agent_config, system_instruction ו-base_environment עם מקורות. הפלטפורמה מספקת ארגז חול חדש עם הקבצים שלכם בכל הפעלה. במאמר סביבות מפורטים סוגי המקורות שזמינים (Git, GCS, inline).
Python
from google import genai
client = genai.Client()
agent = client.agents.create(
id="data-analyst",
base_agent="antigravity-preview-05-2026",
agent_config={
"type": "antigravity",
"model": "gemini-3.8-flash",
},
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",
agent_config: {
type: "antigravity",
model: "gemini-3.8-flash",
},
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}`);
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/agents" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
"id": "data-analyst",
"base_agent": "antigravity-preview-05-2026",
"agent_config": {
"type": "antigravity",
"model": "gemini-3.8-flash"
},
"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"
}
]
}
}'
מסביבה קיימת (פיצול)
מבצעים איטרציה עם סוכן Antigravity הבסיסי עד שהסביבה מתאימה (החבילות מותקנות, הקבצים במקום), ואז יוצרים ממנו עותק (fork) לסוכן מנוהל.
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}`);
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": "Install pandas, matplotlib, and seaborn. Create an analysis template at /workspace/template.py.",
"environment": "remote"
}'
עם כללי רשת
כששומרים סוכן מנוהל, אפשר לנעול את הגישה היוצאת או להוסיף פרטי כניסה. למידע על הסכימה המלאה של רשימת ההיתרים, על תבניות של פרטי כניסה ועל תווים כלליים, אפשר לעיין במאמר סביבות: הגדרת רשת.
בדוגמה הבאה נוצר סוכן issue-resolver שיכול לגשת רק ל-GitHub ול-PyPI, עם פרטי כניסה שמוזרקים ל-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}`);
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/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"}
]
}
}
}'
הפעלת הסוכן
כדי להתקשר לסוכן המנוהל באמצעות מזהה הסוכן, צריך ליצור אינטראקציה חדשה. כל הפעלה יוצרת עותק של סביבת הבסיס, כך שכל הרצה מתחילה בצורה נקייה.
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);
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": "data-analyst",
"input": "Analyze Q1 revenue data from /workspace/templates/sample.csv and create a slide deck.",
"environment": "remote"
}'
למידע על שיחות רב-שלביות וסטרימינג, אפשר לעיין במדריך למתחילים. אותם דפוסי previous_interaction_id ו-environment חלים על סוכנים מנוהלים.
סוכנים מנוהלים תומכים גם בהרצה ברקע וביטול. פרטים ודוגמאות קוד זמינים במאמר Antigravity Agent: Background execution.
שינוי ההגדרה בזמן ההפעלה
כשיוצרים אינטראקציה, אפשר לשנות את הגדרות הרשת שמוגדרות כברירת מחדל לסוכן system_instruction, tools ו-environment. כך אפשר לשנות את ההתנהגות, היכולות או פרטי הכניסה של הסוכן להרצה ספציפית בלי לשנות את הגדרת הסוכן ששמורה.
ביטול ההוראות והכלים של המערכת
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);
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": "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"
}'
שינוי הגדרת הרשת (רענון פרטי הכניסה)
אם לסוכן המנוהל שלכם יש פרטי כניסה לרשת שמוטמעים ב-base_environment, אתם יכולים לבטל אותם בזמן ההפעלה כדי לרענן אסימונים שתוקפם פג או להחליף מפתחות API. מעבירים אובייקט environment עם הגדרה חדשה של network. הכללים החדשים של הרשת מחליפים באופן מלא את הכללים הקודמים לגבי האינטראקציה הזו. המקורות של סביבת הבסיס (קבצים, מאגרים) נשמרים.
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);
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": "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"}
]
}
}
}'
ניהול הסוכנים
אפשר להציג רשימה של סוכנים, לקבל מידע עליהם ולמחוק אותם.
הצגת רשימה של סוכנים
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}`);
}
}
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 GET "https://generativelanguage.googleapis.com/v1beta/agents" \
-H "x-goog-api-key: $GEMINI_API_KEY"
קבלת סוכן
Python
agent = client.agents.get(id="data-analyst")
print(agent)
JavaScript
const agent = await client.agents.get("data-analyst");
console.log(agent);
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 GET "https://generativelanguage.googleapis.com/v1beta/agents/data-analyst" \
-H "x-goog-api-key: $GEMINI_API_KEY"
מחיקת סוכן
המחיקה מסירה את ההגדרה. הסביבות הקיימות והאינטראקציות שנוצרו על ידי הסוכן לא יושפעו.
Python
client.agents.delete(id="data-analyst")
JavaScript
await client.agents.delete("data-analyst");
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 DELETE "https://generativelanguage.googleapis.com/v1beta/agents/data-analyst" \
-H "x-goog-api-key: $GEMINI_API_KEY"
הסבר על הגדרת הסוכן
| שדה | סוג | נדרש | תיאור |
|---|---|---|---|
id |
מחרוזת | כן | מזהה סוכן ייחודי בפרויקט בענן של Google. משמש להפעלת הסוכן. אסור להשתמש בתחיליות שמורות. מידע נוסף על הגבלות על מזהה סוכן |
description |
מחרוזת | לא | תיאור של הסוכן שכתוב בצורה שקריאה לאנשים. |
base_agent |
מחרוזת | כן | מזהה הסוכן הבסיסי (לדוגמה, antigravity-preview-05-2026). |
agent_config |
אובייקט | לא | הגדרות של הסוכן הבסיסי, כולל בחירת מודל ({"type": "antigravity", "model": "gemini-3.8-flash"}). אם לא מציינים מודל, ברירת המחדל היא gemini-3.8-flash. אי אפשר לשנות את ההגדרה הזו במועד האינטראקציה לסוכנים עם שם. |
system_instruction |
מחרוזת | לא | הנחיה למערכת שמגדירה את ההתנהגות והאישיות. |
tools |
מערך | לא | כלים שהסוכן יכול להשתמש בהם. אם לא מציינים ערך, ברירת המחדל היא code_execution, google_search ו-url_context. הכלים הנתמכים כוללים את code_execution, google_search, url_context, mcp_server והגדרות מותאמות אישית של function. |
base_environment |
מחרוזת או אובייקט | לא | "remote", environment_id או אובייקט הגדרה עם sources ו-network. ראו סביבות. |
הגבלות על מזהה הסוכן
כשיוצרים סוכן מנוהל, צריך להקפיד על הכללים הבאים לגבי id שאתם מציינים:
- הוא חייב להיות ייחודי לפרויקט ב-Google Cloud.
- הוא לא יכול להתחיל באחת מהקידומות השמורות הבאות (לא תלויות רישיות), אחרת היצירה תיכשל:
antigravity-veo-omni-lyria-imagen-gemma-gemini-google-youtube-android-chrome-pixel-waze-fitbit-nest-kaggle-
תהליך עבודה של איטרציה
- אב טיפוס עם סוכן Antigravity בסיסי. העברת הוראות למערכת ומקורות סביבה מוטבעים. בדיקה אינטראקטיבית של הוראות, מיומנויות והגדרת הסביבה.
- מייצבים את הסביבה. מתקינים חבילות, מטמיעים מקורות ומוודאים שהכול פועל.
- להפוך לסוכן מנוהל על ידי יצירת סוכן חדש, ממקורות או על ידי פיצול הסביבה.
- מעדכנים את הגדרת הסוכן. לשנות את ההוראה למערכת, להחליף מיומנויות או להוסיף מקורות. ההפעלה הבאה תשתמש בהגדרה החדשה.
מגבלות
- סטטוס התצוגה המקדימה: סוכנים מנוהלים נמצאים בתצוגה מקדימה. יכולים להיות שינויים בתכונות ובסכימות.
- סוכן ומודלים בסיסיים: רק
antigravity-preview-05-2026נתמך כ-base_agent. אפשרויות המודל הנתמכות ב-agent_configהןgemini-3.8-flash(ברירת מחדל),gemini-3.7-flash,gemini-3.6-flash,gemini-3.5-flashו-gemini-3.5-flash-lite. בסוכנים עם שם, אי אפשר לבטל את המודל במועד האינטראקציה. - אין ניהול גרסאות: עדיין אין אפשרות לנהל גרסאות של סוכנים ולחזור לגרסה קודמת.
- אין קינון של סוכני משנה: עדיין אין תמיכה בהעברת הרשאה לסוכני משנה.
- אפשר להוסיף עד 1,000 סוכנים מנוהלים.
המאמרים הבאים
- סקירה כללית על סוכנים: מידע על המושגים המרכזיים של סוכנים מנוהלים.
- מדריך למתחילים: איך מתחילים ליצור שיחות רב-שלביות וסטרימינג.
- Antigravity Agent: מידע על היכולות, הכלים והתמחור של הסוכן שמוגדר כברירת מחדל.
- סביבות של סוכנים: הגדרה של ארגזי חול, מקורות ורשתות.
- Managed Agents API on Agent Platform: ליצירת סוכנים עם ניהול משילות ארגוני מובנה.