Gemini API の Managed Agents を拡張:バックグラウンドタスク、リモート MCP など

@GoogleAIStudio
英語1 日前 · 2026年7月07日
192K
568
73
21
332

TL;DR

Google AI Studio は Gemini API Managed Agents に大幅なアップデートを導入しました。これにより、長時間のバックグラウンドタスク、リモート MCP サーバーへの接続、開発者向けの永続的なサンドボックス状態の管理が可能になります。

本日、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 エージェントのドキュメント を参照してください。

bash
1npm install @google/genai

拡張された機能で自律エージェントを構築

長時間実行のバックグラウンド処理

長時間実行されるタスクのために HTTP 接続を開いたままにしておくのは不安定です。background: true を渡すと、サーバー上で非同期にインタラクションを実行できます。API は即座に ID を返すため、クライアントアプリケーションはその ID を使用してステータスのポーリング、進捗のストリーミング、またはエージェントがリモートで処理を終えた後の再接続を行うことができます。詳細については、バックグラウンド実行ガイド をお読みください。

typescript
1import { GoogleGenAI } from "@google/genai";
2
3const client = new GoogleGenAI({});
4
5// 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});
12
13console.log(`Background task started. Interaction ID: ${interaction.id}`);
14
15// 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}
21
22if (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 でエージェントを拡張する際は、ベストプラクティス に従ってください。

typescript
1import { GoogleGenAI } from "@google/genai";
2
3const client = new GoogleGenAI({});
4
5const 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});
19
20console.log(interaction.output_text);

サンドボックスツールと併用するカスタム関数呼び出し

組み込みのサンドボックスツールと一緒にカスタムツール を追加して、ローカルで実行できます。API はステップマッチングを使用します。組み込みツールはサーバー上で自動的に実行され、カスタム関数はインタラクションを requires_action 状態に遷移させ、クライアントがローカルのビジネスロジックを実行できるようにします。

typescript
1import { GoogleGenAI } from "@google/genai";
2
3const client = new GoogleGenAI({});
4
5// 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};
21
22// 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});
32
33// 3. カスタム関数の実行をクリーンに処理
34if (interaction.status === "requires_action") {
35 // ファイルシステムとサンドボックスツールは自動的に実行され、対応する function_result ステップを生成します。
36 // クライアント側での実行が必要な保留中のドメイン呼び出しをフィルタリングします。
37 const executedCalls = new Set(
38 interaction.steps
39 .filter((s) => s.type === "function_result")
40 .map((s) => s.call_id)
41 );
42
43 const pendingCalls = interaction.steps.filter(
44 (s) => s.type === "function_call" && !executedCalls.has(s.id)
45 );
46
47 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 と新しいネットワーク設定 を渡すことで、認証情報を更新したり、キーをローテーションしたりできます。新しいルールは古いルールを即座に置き換えます。サンドボックスは、ファイルシステムの状態、インストール済みパッケージ、クローンされたリポジトリをそのまま保持します。

typescript
1import { GoogleGenAI } from "@google/genai";
2const client = new GoogleGenAI({});
3
4// 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});
22
23// 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 クイックスタート をチェックして、カスタムエージェント定義、環境設定、ネットワークルール、高度なストリーミングパターンを詳しく調べてください。

ワンクリック保存

YouMindでバイラル記事をAI深読み

Save the source, ask focused questions, summarize the argument, and turn a viral article into reusable notes in one AI workspace.

Explore YouMind
クリエイターのために

あなたの Markdown をきれいな 𝕏 記事に

自分の長文を投稿するとき、画像・表・コードブロックを 𝕏 向けに整形するのは手間がかかります。YouMind は Markdown 全体を、そのまま投稿できるきれいな 𝕏 記事に変換します。

Markdown → 𝕏 を試す

解読すべきパターンをもっと

最近のバイラル記事

バイラル記事をもっと見る