Gemini Deep Research エージェント

Gemini Deep Research エージェントは、複数ステップのリサーチ タスクを自律的に計画、実行、統合します。Gemini 3 Pro を搭載し、ウェブ検索とユーザー自身のデータを使用して複雑な情報環境をナビゲートし、引用文献が記載された詳細なレポートを作成します。

リサーチのタスクでは、反復的な検索と読み取りが行われ、完了までに数分かかることがあります。エージェントを非同期で実行して結果をポーリングするには、バックグラウンド実行background=true を設定)を使用する必要があります。詳細については、長時間実行タスクの処理をご覧ください。

次の例は、バックグラウンドでリサーチ タスクを開始し、結果をポーリングする方法を示しています。

Python

import time
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    input="Research the history of Google TPUs.",
    agent='deep-research-pro-preview-12-2025',
    background=True
)

print(f"Research started: {interaction.id}")

while True:
    interaction = client.interactions.get(interaction.id)
    if interaction.status == "completed":
        print(interaction.outputs[-1].text)
        break
    elif interaction.status == "failed":
        print(f"Research failed: {interaction.error}")
        break
    time.sleep(10)

JavaScript

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

const client = new GoogleGenAI({});

const interaction = await client.interactions.create({
    input: 'Research the history of Google TPUs.',
    agent: 'deep-research-pro-preview-12-2025',
    background: true
});

console.log(`Research started: ${interaction.id}`);

while (true) {
    const result = await client.interactions.get(interaction.id);
    if (result.status === 'completed') {
        console.log(result.outputs[result.outputs.length - 1].text);
        break;
    } else if (result.status === 'failed') {
        console.log(`Research failed: ${result.error}`);
        break;
    }
    await new Promise(resolve => setTimeout(resolve, 10000));
}

REST

# 1. Start the research task
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "input": "Research the history of Google TPUs.",
    "agent": "deep-research-pro-preview-12-2025",
    "background": true
}'

# 2. Poll for results (Replace INTERACTION_ID)
# curl -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/INTERACTION_ID" \
# -H "x-goog-api-key: $GEMINI_API_KEY"

独自のデータでリサーチする

Deep Research はさまざまなツールにアクセスできます。デフォルトでは、エージェントは google_search ツールと url_context ツールを使用して、一般公開されているインターネット上の情報にアクセスできます。デフォルトでは、これらのツールを指定する必要はありません。ただし、ファイル検索ツールを使用してエージェントに独自のデータへのアクセス権を付与する場合は、次の例に示すように追加する必要があります。

Python

import time
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    input="Compare our 2025 fiscal year report against current public web news.",
    agent="deep-research-pro-preview-12-2025",
    background=True,
    tools=[
        {
            "type": "file_search",
            "file_search_store_names": ['fileSearchStores/my-store-name']
        }
    ]
)

JavaScript

const interaction = await client.interactions.create({
    input: 'Compare our 2025 fiscal year report against current public web news.',
    agent: 'deep-research-pro-preview-12-2025',
    background: true,
    tools: [
        { type: 'file_search', file_search_store_names: ['fileSearchStores/my-store-name'] },
    ]
});

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "input": "Compare our 2025 fiscal year report against current public web news.",
    "agent": "deep-research-pro-preview-12-2025",
    "background": true,
    "tools": [
        {"type": "file_search", "file_search_store_names": ["fileSearchStores/my-store-name"]},
    ]
}'

操作性と書式設定

プロンプトで特定の形式の指示を指定することで、エージェントの出力を制御できます。これにより、レポートを特定のセクションやサブセクションに構成したり、データテーブルを含めたり、さまざまなユーザーに合わせてトーンを調整したりできます(例:「技術」、「エグゼクティブ」、「カジュアル」)。

入力テキストで目的の出力形式を明示的に定義します。

Python

prompt = """
Research the competitive landscape of EV batteries.

Format the output as a technical report with the following structure:
1. Executive Summary
2. Key Players (Must include a data table comparing capacity and chemistry)
3. Supply Chain Risks
"""

interaction = client.interactions.create(
    input=prompt,
    agent="deep-research-pro-preview-12-2025",
    background=True
)

JavaScript

const prompt = `
Research the competitive landscape of EV batteries.

Format the output as a technical report with the following structure:
1. Executive Summary
2. Key Players (Must include a data table comparing capacity and chemistry)
3. Supply Chain Risks
`;

const interaction = await client.interactions.create({
    input: prompt,
    agent: 'deep-research-pro-preview-12-2025',
    background: true,
});

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "input": "Research the competitive landscape of EV batteries.\n\nFormat the output as a technical report with the following structure: \n1. Executive Summary\n2. Key Players (Must include a data table comparing capacity and chemistry)\n3. Supply Chain Risks",
    "agent": "deep-research-pro-preview-12-2025",
    "background": true
}'

長時間実行タスクの処理

Deep Research は、計画、検索、読解、執筆を含む複数のステップからなるプロセスです。通常、このサイクルは同期 API 呼び出しの標準のタイムアウト上限を超えます。

background=True を使用するには、エージェントが必要です。API は、部分的な Interaction オブジェクトをすぐに返します。id プロパティを使用すると、ポーリング用のインタラクションを取得できます。インタラクションの状態が in_progress から completed または failed に移行します。

ストリーミング

Deep Research は、調査の進捗状況に関するリアルタイムの更新情報を受け取るためのストリーミングをサポートしています。stream=Truebackground=True を設定する必要があります。

次の例は、リサーチタスクを開始してストリームを処理する方法を示しています。重要なのは、interaction.start イベントから interaction_id をトラッキングする方法を示していることです。ネットワークの中断が発生した場合にストリームを再開するには、この ID が必要になります。このコードでは、切断した特定の時点から再開できる event_id 変数も導入しています。

Python

stream = client.interactions.create(
    input="Research the history of Google TPUs.",
    agent="deep-research-pro-preview-12-2025",
    background=True,
    stream=True,
    agent_config={
        "type": "deep-research",
        "thinking_summaries": "auto"
    }
)

interaction_id = None
last_event_id = None

for chunk in stream:
    if chunk.event_type == "interaction.start":
        interaction_id = chunk.interaction.id
        print(f"Interaction started: {interaction_id}")

    if chunk.event_id:
        last_event_id = chunk.event_id

    if chunk.event_type == "content.delta":
        if chunk.delta.type == "text":
            print(chunk.delta.text, end="", flush=True)
        elif chunk.delta.type == "thought_summary":
            print(f"Thought: {chunk.delta.content.text}", flush=True)

    elif chunk.event_type == "interaction.complete":
        print("\nResearch Complete")

JavaScript

const stream = await client.interactions.create({
    input: 'Research the history of Google TPUs.',
    agent: 'deep-research-pro-preview-12-2025',
    background: true,
    stream: true,
    agent_config: {
        type: 'deep-research',
        thinking_summaries: 'auto'
    }
});

let interactionId;
let lastEventId;

for await (const chunk of stream) {
    // 1. Capture Interaction ID
    if (chunk.event_type === 'interaction.start') {
        interactionId = chunk.interaction.id;
        console.log(`Interaction started: ${interactionId}`);
    }

    // 2. Track IDs for potential reconnection
    if (chunk.event_id) lastEventId = chunk.event_id;

    // 3. Handle Content
    if (chunk.event_type === 'content.delta') {
        if (chunk.delta.type === 'text') {
            process.stdout.write(chunk.delta.text);
        } else if (chunk.delta.type === 'thought_summary') {
            console.log(`Thought: ${chunk.delta.content.text}`);
        }
    } else if (chunk.event_type === 'interaction.complete') {
        console.log('\nResearch Complete');
    }
}

REST

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?alt=sse" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "input": "Research the history of Google TPUs.",
    "agent": "deep-research-pro-preview-12-2025",
    "background": true,
    "stream": true,
    "agent_config": {
        "type": "deep-research",
        "thinking_summaries": "auto"
    }
}'
# Note: Look for the 'interaction.start' event to get the interaction ID.

ストリームに再接続しています

長時間実行される調査タスク中にネットワークが中断されることがあります。この問題を適切に処理するには、アプリケーションで接続エラーをキャッチし、client.interactions.get() を使用してストリームを再開する必要があります。

再開するには、次の 2 つの値を指定する必要があります。

  1. Interaction ID: 初期ストリームの interaction.start イベントから取得されます。
  2. Last Event ID: 最後に正常に処理されたイベントの ID。これにより、サーバーは、その特定のポイントのにイベントの送信を再開します。指定しない場合、ストリームの先頭が返されます。

次の例は、復元力のあるパターンを示しています。最初の create リクエストのストリーミングを試み、接続が切断された場合は get ループにフォールバックします。

Python

import time
from google import genai

client = genai.Client()

# Configuration
agent_name = 'deep-research-pro-preview-12-2025'
prompt = 'Compare golang SDK test frameworks'

# State tracking
last_event_id = None
interaction_id = None
is_complete = False

def process_stream(event_stream):
    """Helper to process events from any stream source."""
    global last_event_id, interaction_id, is_complete
    for event in event_stream:
        # Capture Interaction ID
        if event.event_type == "interaction.start":
            interaction_id = event.interaction.id
            print(f"Interaction started: {interaction_id}")

        # Capture Event ID
        if event.event_id:
            last_event_id = event.event_id

        # Print content
        if event.event_type == "content.delta":
            if event.delta.type == "text":
                print(event.delta.text, end="", flush=True)
            elif event.delta.type == "thought_summary":
                print(f"Thought: {event.delta.content.text}", flush=True)

        # Check completion
        if event.event_type in ['interaction.complete', 'error']:
            is_complete = True

# 1. Attempt initial streaming request
try:
    print("Starting Research...")
    initial_stream = client.interactions.create(
        input=prompt,
        agent=agent_name,
        background=True,
        stream=True,
        agent_config={
            "type": "deep-research",
            "thinking_summaries": "auto"
        }
    )
    process_stream(initial_stream)
except Exception as e:
    print(f"\nInitial connection dropped: {e}")

# 2. Reconnection Loop
# If the code reaches here and is_complete is False, we resume using .get()
while not is_complete and interaction_id:
    print(f"\nConnection lost. Resuming from event {last_event_id}...")
    time.sleep(2) 

    try:
        resume_stream = client.interactions.get(
            id=interaction_id,
            stream=True,
            last_event_id=last_event_id
        )
        process_stream(resume_stream)
    except Exception as e:
        print(f"Reconnection failed, retrying... ({e})")

JavaScript

let lastEventId;
let interactionId;
let isComplete = false;

// Helper to handle the event logic
const handleStream = async (stream) => {
    for await (const chunk of stream) {
        if (chunk.event_type === 'interaction.start') {
            interactionId = chunk.interaction.id;
        }
        if (chunk.event_id) lastEventId = chunk.event_id;

        if (chunk.event_type === 'content.delta') {
            if (chunk.delta.type === 'text') {
                process.stdout.write(chunk.delta.text);
            } else if (chunk.delta.type === 'thought_summary') {
                console.log(`Thought: ${chunk.delta.content.text}`);
            }
        } else if (chunk.event_type === 'interaction.complete') {
            isComplete = true;
        }
    }
};

// 1. Start the task with streaming
try {
    const stream = await client.interactions.create({
        input: 'Compare golang SDK test frameworks',
        agent: 'deep-research-pro-preview-12-2025',
        background: true,
        stream: true,
        agent_config: {
            type: 'deep-research',
            thinking_summaries: 'auto'
        }
    });
    await handleStream(stream);
} catch (e) {
    console.log('\nInitial stream interrupted.');
}

// 2. Reconnect Loop
while (!isComplete && interactionId) {
    console.log(`\nReconnecting to interaction ${interactionId} from event ${lastEventId}...`);
    try {
        const stream = await client.interactions.get(interactionId, {
            stream: true,
            last_event_id: lastEventId
        });
        await handleStream(stream);
    } catch (e) {
        console.log('Reconnection failed, retrying in 2s...');
        await new Promise(resolve => setTimeout(resolve, 2000));
    }
}

REST

# 1. Start the research task (Initial Stream)
# Watch for event: interaction.start to get the INTERACTION_ID
# Watch for "event_id" fields to get the LAST_EVENT_ID
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions?alt=sse" \
-H "Content-Type: application/json" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-d '{
    "input": "Compare golang SDK test frameworks",
    "agent": "deep-research-pro-preview-12-2025",
    "background": true,
    "stream": true,
    "agent_config": {
        "type": "deep-research",
        "thinking_summaries": "auto"
    }
}'

# ... Connection interrupted ...

# 2. Reconnect (Resume Stream)
# Pass the INTERACTION_ID and the LAST_EVENT_ID you saved.
curl -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/INTERACTION_ID?stream=true&last_event_id=LAST_EVENT_ID&alt=sse" \
-H "x-goog-api-key: $GEMINI_API_KEY"

フォローアップの質問とやり取り

エージェントが最終レポートを返した後に会話を続けるには、previous_interaction_id を使用します。これにより、タスク全体を再開することなく、調査の特定の部分について説明、要約、詳細を求めることができます。

Python

import time
from google import genai

client = genai.Client()

interaction = client.interactions.create(
    input="Can you elaborate on the second point in the report?",
    model="gemini-3-pro-preview",
    previous_interaction_id="COMPLETED_INTERACTION_ID"
)

print(interaction.outputs[-1].text)

JavaScript

const interaction = await client.interactions.create({
    input: 'Can you elaborate on the second point in the report?',
    agent: 'deep-research-pro-preview-12-2025',
    previous_interaction_id: 'COMPLETED_INTERACTION_ID'
});
console.log(interaction.outputs[-1].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 '{
    "input": "Can you elaborate on the second point in the report?",
    "agent": "deep-research-pro-preview-12-2025",
    "previous_interaction_id": "COMPLETED_INTERACTION_ID"
}'

Gemini Deep Research エージェントを使用する場合

Deep Research は単なるモデルではなく、エージェントです。低レイテンシのチャットではなく、「アナリスト イン ア ボックス」のアプローチを必要とするワークロードに最適です。

機能 標準の Gemini モデル Gemini Deep Research エージェント
レイテンシ 分(非同期/バックグラウンド)
プロセス 生成 -> 出力 計画 -> 検索 -> 読み取り -> 反復 -> 出力
出力 会話テキスト、コード、短い要約 詳細なレポート、長文の分析、比較表
最適な用途 Chatbot、抽出、クリエイティブ ライティング 市場分析、デュー デリジェンス、文献レビュー、競合状況の分析

リリース情報と料金

  • 利用可能状況: Google AI Studio と Gemini API の Interactions API を使用してアクセスできます。
  • 料金: 料金と詳細については、料金ページをご覧ください。

安全上の考慮事項

エージェントにウェブとプライベート ファイルへのアクセス権を付与する場合は、安全上のリスクを慎重に検討する必要があります。

  • ファイルを使用したプロンプト インジェクション: エージェントは、ユーザーが提供したファイルの内容を読み取ります。アップロードされたドキュメント(PDF、テキスト ファイル)が信頼できるソースからのものであることを確認します。悪意のあるファイルには、エージェントの出力を操作するように設計された隠しテキストが含まれている可能性があります。
  • ウェブ コンテンツのリスク: エージェントが公開ウェブを検索します。堅牢なセーフティ フィルタを実装していますが、エージェントが悪意のあるウェブページに遭遇して処理するリスクがあります。回答で提供された citations を確認して、ソースを検証することをおすすめします。
  • データ流出: エージェントに機密性の高い内部データの要約を依頼する際に、ウェブの閲覧も許可している場合は注意が必要です。

ベスト プラクティス

  • 不明な場合のプロンプト: データが欠落している場合の処理方法をエージェントに指示します。たとえば、プロンプトに「2025 年の具体的な数値が利用できない場合は、推定ではなく、予測または利用できないことを明示的に述べてください」を追加します。
  • コンテキストを提供する: 入力プロンプトで背景情報や制約を直接指定して、エージェントの調査をグラウンディングします。
  • マルチモーダル入力: Deep Research エージェントはマルチモーダル入力をサポートしています。コストが増加し、コンテキスト ウィンドウのオーバーフローのリスクが高まるため、注意して使用してください。

制限事項

  • ベータ版のステータス: Interactions API は公開ベータ版です。機能とスキーマは変更される可能性があります。
  • カスタムツール: 現在、カスタムの関数呼び出しツールやリモート MCP(Model Context Protocol)サーバーを Deep Research エージェントに提供することはできません。
  • 構造化された出力と計画の承認: Deep Research Agent は現在、人間が承認した計画や構造化された出力をサポートしていません。
  • 最大調査時間: Deep Research エージェントの最大調査時間は 60 分です。ほとんどのタスクは 20 分以内に完了します。
  • ストアの要件: background=True を使用したエージェントの実行には store=True が必要です。
  • Google 検索: Google 検索はデフォルトで有効になっており、グラウンディングされた検索結果には特定の制限が適用されます。
  • 音声入力: 音声入力はサポートされていません。

次のステップ

  • 操作用 API の詳細をご確認ください。
  • このエージェントを強化する Gemini 3 Pro モデルについて確認する。
  • ファイル検索ツールを使用して独自のデータを使用する方法について説明します。