Antigravity 에이전트

Antigravity 에이전트는 Gemini API의 범용 관리형 에이전트입니다. 단일 API 호출을 통해 Google에서 호스팅하는 자체 보안 Linux 샌드박스 내에서 추론하고, 코드를 실행하고, 파일을 관리하고, 웹을 탐색하는 에이전트를 얻을 수 있습니다.

Gemini 3.7 Flash로 구동되며 Antigravity IDE와 동일한 하네스를 사용합니다. agent_config를 사용하여 기본 Gemini 모델을 구성할 수 있습니다. Interactions APIGoogle AI Studio를 통해 사용할 수 있습니다.

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    agent="antigravity-preview-05-2026",
    input="Read Hacker News, summarize the top 10 stories, and save the results as a PDF.",
    environment="remote",
)

print(interaction.output_text)

자바스크립트

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
    agent: "antigravity-preview-05-2026",
    input: "Read Hacker News, summarize the top 10 stories, and save the results as a PDF.",
    environment: "remote",
}, { 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": "Read Hacker News, summarize the top 10 stories, and save the results as a PDF.",
    "environment": "remote"
}'

기능

각 호출은 Linux 샌드박스를 프로비저닝하고 도구 사용 루프를 시작할 수 있습니다. 에이전트는 작업을 완료할 때까지 계획하고, 행동하고, 결과를 관찰하고, 이를 반복합니다.

  • 코드 실행: Bash, Python, Node.js 명령어를 실행합니다. 패키지 설치, 테스트 실행, 앱 빌드
  • 파일 관리: 샌드박스에서 파일을 읽고, 쓰고, 수정하고, 검색하고, 나열합니다. 파일은 상호작용 전반에 걸쳐 유지됩니다.
  • 웹 액세스: 데이터에 대한 Google 검색 및 URL 가져오기
  • 컨텍스트 압축: 컨텍스트를 손실하거나 토큰 한도에 도달하지 않고 장기 실행 멀티턴 세션을 지원하기 위해 자동 컨텍스트 압축이 트리거됩니다 (~135, 000개 토큰).

멀티턴 사용 및 스트리밍은 빠른 시작을 참고하세요.

지원되는 도구

기본적으로 에이전트는 code_execution, google_search, url_context에 액세스할 수 있습니다. environment 매개변수를 지정하면 파일 시스템 도구가 자동으로 사용 설정됩니다. 맞춤 함수를 정의하여 에이전트를 자체 API 및 도구에 연결할 수도 있습니다. 기본 세트를 맞춤설정하거나 제한할 때 또는 맞춤 함수를 추가할 때만 tools 매개변수를 지정하면 됩니다.

도구 유형 값 설명
코드 실행 code_execution stdout/stderr 캡처를 사용하여 셸 명령어 (bash, Python, Node)를 실행합니다.
Google 검색 google_search 공개 웹을 검색합니다.
URL 컨텍스트 url_context 웹페이지를 가져오고 읽습니다.
파일 시스템 (environment을 통해 사용 설정됨) 샌드박스에서 파일을 읽고, 쓰고, 수정하고, 검색하고, 나열합니다. environment를 설정하면 시스템에서 이러한 도구를 자동으로 사용 설정합니다.
맞춤 함수 function 에이전트가 실행을 요청할 수 있는 맞춤 함수를 정의합니다. 함수 호출을 참조하세요.
원격 MCP 서버 mcp_server 외부 모델 컨텍스트 프로토콜 (MCP) 서버를 도구로 등록합니다. MCP 서버를 참고하세요.

동기 후크를 사용하여 원격 샌드박스 내에서 바로 code_executionfilesystem 도구 실행을 가로채고 검증할 수 있습니다.

에이전트를 특정 도구로 제한하려면 필요한 도구만 전달하세요.

Python

from google import genai

client = genai.Client()

interaction = client.interactions.create(
    agent="antigravity-preview-05-2026",
    input="Search for the latest AI research papers on reasoning and summarize them.",
    environment="remote",
    tools=[
        {"type": "google_search"},
        {"type": "url_context"},
    ],
)

print(interaction.output_text)

자바스크립트

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
    agent: "antigravity-preview-05-2026",
    input: "Search for the latest AI research papers on reasoning and summarize them.",
    environment: "remote",
    tools: [
        { type: "google_search" },
        { type: "url_context" },
    ],
}, { 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": "Search for the latest AI research papers on reasoning and summarize them.",
    "environment": "remote",
    "tools": [
        {"type": "google_search"},
        {"type": "url_context"}
    ]
}'

멀티모달 입력

Antigravity 에이전트는 멀티모달 입력을 지원합니다. 현재 textimage 입력만 지원됩니다. 이미지는 인라인 base64 인코딩 문자열 (data)로 제공해야 합니다.

Python

import base64
from google import genai

client = genai.Client()

with open("path/to/chart.png", "rb") as f:
    image_bytes = f.read()

interaction_inline = client.interactions.create(
    agent="antigravity-preview-05-2026",
    input=[
        {"type": "text", "text": "Analyze this chart and summarize the trends."},
        {
            "type": "image",
            "data": base64.b64encode(image_bytes).decode("utf-8"),
            "mime_type": "image/png",
        },
    ],
    environment="remote",
)

자바스크립트


import { GoogleGenAI } from "@google/genai";

import * as fs from "node:fs";

const client = new GoogleGenAI({});
const base64Image = fs.readFileSync("path/to/chart.png", { encoding: "base64" });

const interactionInline = await client.interactions.create({
    agent: "antigravity-preview-05-2026",
    input: [
        { type: "text", text: "Analyze this chart and summarize the trends." },
        {
            type: "image",
            data: base64Image,
            mime_type: "image/png",
        },
    ],
    environment: "remote",
}, { timeout: 300000 });

REST

BASE64_IMAGE=$(base64 -w0 /path/to/chart.png)

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\": [
        {\"type\": \"text\", \"text\": \"Analyze this chart and summarize the trends.\"},
        {
            \"type\": \"image\",
            \"mime_type\": \"image/png\",
            \"data\": \"$BASE64_IMAGE\"
        }
    ],
    \"environment\": \"remote\"
}"

함수 호출

함수 호출을 사용하면 에이전트가 호출할 수 있는 맞춤 도구를 정의하여 Antigravity 에이전트를 외부 API 및 데이터베이스에 연결할 수 있습니다. 일반적인 개념은 Gemini API를 사용한 함수 호출을 참고하세요.

다음 예는 2턴 상호작용을 보여줍니다. 에이전트는 먼저 맞춤 get_weather 함수 호출을 요청하고 클라이언트는 이를 실행하고 두 번째 턴에서 결과를 반환합니다.

Python

from google import genai

client = genai.Client()

# 1. Define the custom function
get_weather_tool = {
    "type": "function",
    "name": "get_weather",
    "description": "Gets the current weather for a given location.",
    "parameters": {
        "type": "object",
        "properties": {
            "location": {
                "type": "string",
                "description": "The city and country, e.g. San Francisco, USA",
            }
        },
        "required": ["location"],
    },
}

# 2. Call the agent with the custom tool (Turn 1)
interaction = client.interactions.create(
    agent="antigravity-preview-05-2026",
    input="What is the weather in Tokyo?",
    environment="remote",
    tools=[
        {"type": "code_execution"},  # Enable default code execution
        get_weather_tool,            # Add custom function
    ],
)

# Check if the agent requested a function call
if interaction.status == "requires_action":
    # Find function calls that do not have a matching function result.
    # Filesystem tools (like write_file) are also represented as function calls
    # but are executed automatically by the environment.
    executed_calls = {step.call_id for step in interaction.steps if step.type == "function_result"}
    pending_calls = [step for step in interaction.steps if step.type == "function_call" and step.id not in executed_calls]

    if pending_calls:
        fc_step = pending_calls[0]
        print(f"Function to call: {fc_step.name} (ID: {fc_step.id})")
        print(f"Arguments: {fc_step.arguments}")

        # 3. Execute the function locally (simulated get_weather()) and send the result back (Turn 2)
        function_result = {
            "temperature": 23,
            "unit": "celsius"
        }

        final_interaction = client.interactions.create(
            agent="antigravity-preview-05-2026",
            previous_interaction_id=interaction.id,  # Reference the interaction ID
            environment=interaction.environment_id,
            input=[
                {
                    "type": "function_result",
                    "name": fc_step.name,
                    "call_id": fc_step.id,
                    "result": function_result,
                }
            ],
        )

        print(final_interaction.output_text)
        # Output: The current weather in Tokyo, Japan is 23°C (Celsius).
    else:
        print("No pending function calls.")
else:
    print(f"Interaction completed with status: {interaction.status}")

자바스크립트

import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

// 1. Define the custom function
const get_weather_tool = {
  type: "function",
  name: "get_weather",
  description: "Gets the current weather for a given location.",
  parameters: {
    type: "object",
    properties: {
      location: {
        type: "string",
        description: "The city and country, e.g. San Francisco, USA",
      },
    },
    required: ["location"],
  },
};

// 2. Call the agent with the custom tool (Turn 1)
const interaction = await client.interactions.create({
  agent: "antigravity-preview-05-2026",
  input: "What is the weather in Tokyo?",
  environment: "remote",
  tools: [
    { type: "code_execution" },
    get_weather_tool,
  ],
}, { timeout: 300000 });

if (interaction.status === "requires_action") {
  // Find function calls that do not have a matching function result.
  // Filesystem tools (like write_file) are also represented as function calls
  // but are executed automatically by the environment.
  const executedCalls = new Set(
    interaction.steps
      .filter(s => s.type === "function_result")
      .map(s => s.call_id)
  );
  const pendingCalls = interaction.steps.filter(
    s => s.type === "function_call" && !executedCalls.has(s.id)
  );

  if (pendingCalls.length > 0) {
    const fcStep = pendingCalls[0];
    console.log(`Function to call: ${fcStep.name} (ID: ${fcStep.id})`);

    // 3. Execute the function locally (simulated get_weather()) and send the result back (Turn 2)
    const functionResult = {
      temperature: 23,
      unit: "celsius"
    };

    const finalInteraction = await client.interactions.create({
      agent: "antigravity-preview-05-2026",
      previous_interaction_id: interaction.id, // Reference the interaction ID
      environment: interaction.environment_id,
      input: [
        {
          type: "function_result",
          name: fcStep.name,
          call_id: fcStep.id,
          result: functionResult,
        }
      ],
    }, { timeout: 300000 });

    console.log(finalInteraction.output_text);
  } else {
    console.log("No pending function calls.");
  }
} else {
  console.log(`Interaction completed with status: ${interaction.status