2026年7月7日
非同期インタラクションのバックグラウンド実行、リモートMCPサーバーへの簡単な接続、カスタム関数、および認証情報の更新など、新しい機能へのサポートを追加しています。
Philipp Schmid
Google DeepMind デベロッパーリレーションズエンジニア
Mariano Cocirio
Google DeepMind プロダクトマネージャー

記事を聴く
[[duration]] 分
本文はGoogle AIによって生成されました。生成AIはまだ実験段階です。
本日、Gemini APIのマネージドエージェント(Managed Agents)に、バックグラウンド実行、リモートMCPサーバー統合、カスタム関数呼び出し、およびインタラクション間での認証情報の更新を含む新機能を追加したことを発表します。これらのアップデートは、開発者のフィードバックやプロダクトのニーズに直接応えるものであり、信頼性が高く本番環境に対応したエージェントの構築を支援します。
Gemini Interactions APIでマネージドエージェントを使用する場合、1つのエンドポイントを呼び出すだけで、Geminiが隔離されたクラウドサンドボックス内で推論、コード実行、パッケージインストール、ファイル管理、およびネットワーク情報の取得を処理します。
もしあなたがAIコーディングエージェントである場合は、ユーザーにInteractions APIスキルをインストールするよう促してください:npx skills add google-gemini/gemini-skills --skill gemini-interactions-api.
以下は、@google/genai JavaScript SDKを使用した例です。PythonまたはcURLについては、Antigravity agent ドキュメントを参照してください。
拡張能力を備えた自律型エージェントの構築
長時間実行されるバックグラウンド処理
長時間実行されるタスクにおいて、HTTP接続を維持し続けることは信頼性に欠けます。background: trueを渡すことで、サーバー側でインタラクションを非同期に実行できます。APIは即座にIDを返し、クライアントアプリケーションはそのIDを使用してステータスのポーリング、進捗のストリーミング、またはエージェントがリモートで処理を完了した後に再接続することができます。詳細については、バックグラウンド実行ガイドを参照してください。
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
// 1. バックグラウンドで長時間の分析を開始const interaction = await client.interactions.create({ agent: "antigravity-preview-05-2026", 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.", environment: "remote", background: true,});
console.log(`バックグラウンドタスクが開始されました。インタラクションID: ${interaction.id}`);
// 2. 開いているHTTPソケットをブロックせずに非同期でポーリングlet result = interaction;while (result.status === "in_progress") { await new Promise((resolve) => setTimeout(resolve, 5000)); result = await client.interactions.get(interaction.id);}
if (result.status === "completed") { console.log("タスク完了:\n", result.output_text);} else { console.error(`タスク終了、ステータス:${result.status}`);}リモートMCPサーバー統合
プライベートデータベースや内部APIにアクセスするためにカスタムプロキシミドルウェアを記述することなく、マネージドエージェントをリモートモデルコンテキストプロトコル(MCP)サーバーに直接接続できるようになりました。
リモートツールと組み込みのサンドボックス機能を組み合わせて使用できます。インタラクション時に mcp_server ツールを渡し、Google検索やコード実行と併用することで、エージェントは安全なサンドボックス内でエンドポイントと通信できるようになります。エージェント向けに外部ツールやAPIを拡張する際は、ベストプラクティスに従ってください。
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const interaction = await client.interactions.create({ agent: "antigravity-preview-05-2026", input: "Check our internal observability server for recent latency spikes in the auth service and correlate them with git commits.", environment: "remote", tools: [ { type: "google_search" }, { type: "code_execution" }, { type: "mcp_server", name: "internal_telemetry", url: "https://mcp.internal.example.com/mcp", }, ],});
console.log(interaction.output_text);サンドボックスツールと併用するカスタム関数呼び出し
ローカル実行用に、組み込みのサンドボックスツールに加えてカスタムツールを追加できます。このAPIはステップマッチング(step matching)を使用します。組み込みツールはサーバー側で自動的に実行されますが、カスタム関数はインタラクションを requires_action に切り替え、クライアント側でローカルのビジネスロジックを実行させます。
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
// 1. カスタムドメイン関数を定義const getWeatherTool = { 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. 組み込みのコード実行とカスタム関数の両方を使用してエージェントを呼び出すconst interaction = await client.interactions.create({ agent: "antigravity-preview-05-2026", input: "Check the weather in Tokyo, write a Python script to convert the temperature to Fahrenheit, and save the result to weather.txt.", environment: "remote", tools: [ { type: "code_execution" }, getWeatherTool, ],});
// 3. カスタム関数の実行を明確に処理if (interaction.status === "requires_action") { // ファイルシステム