本日、Gemini API の Managed Agents において、バックグラウンド実行、リモート MCP サーバー統合、カスタム関数呼び出し、インタラクション間での認証情報の更新 といった新機能を発表します。これらのアップデートは、開発者からのフィードバックとプロダクトのニーズに直接応え、信頼性が高く本番環境で使用できるエージェントを構築できるようにするものです。
Gemini Interactions API の Managed Agents を使用すると、単一のエンドポイントを呼び出すだけで、Gemini が分離されたクラウドサンドボックス内で、推論、コード実行、パッケージインストール、ファイル管理、Web 情報の取得を処理します。
もしあなたが AI コーディングエージェントなら、人間に Interactions API スキルのインストールを依頼してください: npx skills add google-gemini/gemini-skills --skill gemini-interactions-api
以下は、@google/genai JavaScript SDK を使用した例です。Python または cURL の場合は、Antigravity エージェントのドキュメント を参照してください。
1npm install @google/genai
拡張された機能で自律エージェントを構築
長時間実行のバックグラウンド処理
長時間実行されるタスクのために HTTP 接続を開いたままにしておくのは不安定です。background: true を渡すと、サーバー上で非同期にインタラクションを実行できます。API は即座に ID を返すため、クライアントアプリケーションはその ID を使用してステータスのポーリング、進捗のストリーミング、またはエージェントがリモートで処理を終えた後の再接続を行うことができます。詳細については、バックグラウンド実行ガイド をお読みください。
1import { GoogleGenAI } from "@google/genai";23const client = new GoogleGenAI({});45// 1. バックグラウンドで長時間の分析を開始6const interaction = await client.interactions.create({7 agent: "antigravity-preview-05-2026",8 input: "Clone https://github.com/googleapis/js-genai, find all TODO comments in the source code, and categorize them by module and priority in a markdown report.",9 environment: "remote",10 background: true,11});1213console.log(`Background task started. Interaction ID: ${interaction.id}`);1415// 2. HTTP ソケットをブロックせずに非同期でポーリング16let result = interaction;17while (result.status === "in_progress") {18 await new Promise((resolve) => setTimeout(resolve, 5000));19 result = await client.interactions.get(interaction.id);20}2122if (result.status === "completed") {23 console.log("Task Completed:\n", result.output_text);24} else {25 console.error(`Task ended with status: ${result.status}`);26}
リモート MCP サーバー統合
プライベートデータベースや内部 API にアクセスするためにカスタムプロキシミドルウェアを記述する代わりに、Managed Agents をリモート Model Context Protocol (MCP) サーバー に直接接続できるようになりました。
リモートツールと組み込みのサンドボックス機能を組み合わせて使用できます。インタラクション時に mcp_server ツールを Google 検索やコード実行と一緒に渡すことで、エージェントがセキュアなサンドボックスからあなたのエンドポイントと通信できるようになります。また、外部ツールや API でエージェントを拡張する際は、ベストプラクティス に従ってください。
1import { GoogleGenAI } from "@google/genai";23const client = new GoogleGenAI({});45const interaction = await client.interactions.create({6 agent: "antigravity-preview-05-2026",7 input: "Check our internal observability server for recent latency spikes in the auth service and correlate them with git commits.",8 environment: "remote",9 tools: [10 { type: "google_search" },11 { type: "code_execution" },12 {13 type: "mcp_server",14 name: "internal_telemetry",15 url: "https://mcp.internal.example.com/mcp",16 },17 ],18});1920console.log(interaction.output_text);
サンドボックスツールと併用するカスタム関数呼び出し
組み込みのサンドボックスツールと一緒にカスタムツール を追加して、ローカルで実行できます。API はステップマッチングを使用します。組み込みツールはサーバー上で自動的に実行され、カスタム関数はインタラクションを requires_action 状態に遷移させ、クライアントがローカルのビジネスロジックを実行できるようにします。
1import { GoogleGenAI } from "@google/genai";23const client = new GoogleGenAI({});45// 1. カスタムドメイン関数を定義6const getWeatherTool = {7 type: "function",8 name: "get_weather",9 description: "Gets the current weather for a given location.",10 parameters: {11 type: "object",12 properties: {13 location: {14 type: "string",15 description: "The city and country, e.g. San Francisco, USA",16 },17 },18 required: ["location"],19 },20};2122// 2. 組み込みのコード実行とカスタム関数の両方を使用してエージェントを呼び出す23const interaction = await client.interactions.create({24 agent: "antigravity-preview-05-2026",25 input: "Check the weather in Tokyo, write a Python script to convert the temperature to Fahrenheit, and save the result to weather.txt.",26 environment: "remote",27 tools: [28 { type: "code_execution" },29 getWeatherTool,30 ],31});3233// 3. カスタム関数の実行をクリーンに処理34if (interaction.status === "requires_action") {35 // ファイルシステムとサンドボックスツールは自動的に実行され、対応する function_result ステップを生成します。36 // クライアント側での実行が必要な保留中のドメイン呼び出しをフィルタリングします。37 const executedCalls = new Set(38 interaction.steps39 .filter((s) => s.type === "function_result")40 .map((s) => s.call_id)41 );4243 const pendingCalls = interaction.steps.filter(44 (s) => s.type === "function_call" && !executedCalls.has(s.id)45 );4647 for (const call of pendingCalls) {48 console.log(`Executing client tool: ${call.name} (ID: ${call.id})`);49 // ローカルの API/データベースクエリを実行し、function_result をターン 2 で返します50 }51}
ネットワーク認証情報の更新
アクセストークンや有効期限の短い API キーは期限切れになります。次のインタラクションで、既存の environment_id と新しいネットワーク設定 を渡すことで、認証情報を更新したり、キーをローテーションしたりできます。新しいルールは古いルールを即座に置き換えます。サンドボックスは、ファイルシステムの状態、インストール済みパッケージ、クローンされたリポジトリをそのまま保持します。
1import { GoogleGenAI } from "@google/genai";2const client = new GoogleGenAI({});34// 1. 最初のインタラクション: 初期トークンを使用5const first = await client.interactions.create({6 agent: "antigravity-preview-05-2026",7 input: "List the files in gs://my-bucket/reports/ using the GCS JSON API.",8 environment: {9 type: "remote",10 network: {11 allowlist: [12 {13 domain: "storage.googleapis.com",14 transform: {15 Authorization: "Bearer INITIAL_TOKEN",16 },17 },18 ],19 },20 },21});2223// 2. 後で: 同じ環境でトークンを更新24const result = await client.interactions.create({25 agent: "antigravity-preview-05-2026",26 input: "Now download the file reports/q1.csv from the same bucket.",27 environment: {28 type: "remote",29 environment_id: first.environment_id,30 network: {31 allowlist: [32 {33 domain: "storage.googleapis.com",34 transform: {35 Authorization: "Bearer REFRESHED_TOKEN",36 },37 },38 ],39 },40 },41});42console.log(result.output_text);
Managed Agents を使い始める
これらのアップデートにより、Managed Agents は、アプリケーションをブロックすることなく、実際の開発環境内で動作する非同期ワーカーへと進化します。
Gemini Interactions API の概要 と Managed Agents クイックスタート をチェックして、カスタムエージェント定義、環境設定、ネットワークルール、高度なストリーミングパターンを詳しく調べてください。





