סוכן Deep Research של Gemini מתכנן, מבצע ומסכם באופן אוטונומי משימות מחקר מרובות שלבים. התכונה מבוססת על 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"]},
]
}'
הכוונה ועיצוב
אתם יכולים להנחות את הפלט של הסוכן באמצעות מתן הוראות ספציפיות לעיצוב בהנחיה. כך תוכלו לחלק את הדוחות לקטעים ולתת-קטעים ספציפיים, לכלול טבלאות נתונים או להתאים את הטון לקהלים שונים (למשל, 'technical', 'executive', 'casual').
להגדיר באופן מפורש את פורמט הפלט הרצוי בטקסט הקלט.
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=True ואת background=True.
בדוגמה הבאה אפשר לראות איך מתחילים משימת מחקר ומעבדים את הסטרימינג.
חשוב לציין שהסרטון מראה איך לעקוב אחרי האירוע interaction_id מתוך האירוע interaction.start. תצטרכו את המזהה הזה כדי להמשיך את השידור אם תהיה הפרעה ברשת. הקוד הזה כולל גם משתנה 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().
כדי להמשיך, צריך לציין שני ערכים:
- מזהה אינטראקציה: נרכש מהאירוע
interaction.startבזרם הראשוני. - מזהה האירוע האחרון: המזהה של האירוע האחרון שעבר עיבוד בהצלחה. הפקודה הזו אומרת לשרת להמשיך לשלוח אירועים אחרי הנקודה הספציפית הזו. אם לא תציינו את השעה, תקבלו את תחילת השידור.
בדוגמאות הבאות מוצג דפוס עמיד: ניסיון להזרים את הבקשה הראשונית 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 Agent
Deep Research הוא סוכן, ולא רק מודל. היא מתאימה במיוחד לעומסי עבודה שדורשים גישה של "אנליסט בקופסה" ולא צ'אט עם זמן אחזור נמוך.
| תכונה | מודלים רגילים של Gemini | Gemini Deep Research Agent |
|---|---|---|
| זמן אחזור | שניות | דקות (אסינכרוני/ברקע) |
| Process | יצירה -> פלט | תכנון -> חיפוש -> קריאה -> חזרה על הפעולה -> פלט |
| פלט | טקסט שיחה, קוד, סיכומים קצרים | דוחות מפורטים, ניתוח ארוך, טבלאות השוואה |
| הכי מתאים ל | צ'אטבוטים, חילוץ, כתיבה יוצרת | ניתוח שוק, בדיקת נאותות, סקירת ספרות, ניתוח מצב התחרות |
זמינות ומחירים
- זמינות: אפשר לגשת אליו באמצעות Interactions API ב-Google AI Studio וב-Gemini API.
- מחירים: פרטים ותעריפים ספציפיים מופיעים בדף המחירים.
שיקולי בטיחות
כשנותנים לסוכן גישה לאינטרנט ולקבצים פרטיים, צריך לשקול היטב את סיכוני הבטיחות.
- החדרת הנחיות באמצעות קבצים: הסוכן קורא את התוכן של הקבצים שאתם מספקים. חשוב לוודא שהמסמכים שהועלו (קובצי PDF, קובצי טקסט) מגיעים ממקורות מהימנים. קובץ זדוני יכול להכיל טקסט מוסתר שנועד לתמרן את הפלט של הסוכן.
- סיכונים שקשורים לתוכן באינטרנט: הסוכן מחפש באינטרנט הציבורי. אנחנו מיישמים מסנני בטיחות חזקים, אבל קיים סיכון שהסוכן ייתקל בדפי אינטרנט זדוניים ויעבד אותם. מומלץ לעיין ב
citationsשצוינו בתשובה כדי לאמת את המקורות. - העברת נתונים: חשוב להיזהר כשמבקשים מ-Agent לסכם נתונים פנימיים רגישים אם מאפשרים לו גם לגלוש באינטרנט.
שיטות מומלצות
- הנחיה לגבי נתונים לא ידועים: הנחיה של הסוכן לגבי אופן הטיפול בנתונים חסרים. לדוגמה, אפשר להוסיף את ההנחיה "אם נתונים ספציפיים לשנת 2025 לא זמינים, ציין במפורש שהם תחזיות או לא זמינים, במקום להעריך".
- מספקים הקשר: כדי שהסוכן יתמקד במחקר, אפשר לספק לו מידע רקע או מגבלות ישירות בהנחיית הקלט.
- קלט מרובה מצבים סוכן Deep Research תומך בקלט מרובה מצבים. צריך להשתמש בזה בזהירות, כי זה מגדיל את העלויות ואת הסיכון לחריגה מחלון ההקשר.
מגבלות
- סטטוס בטא: ממשק Interactions API נמצא בגרסת בטא ציבורית. יכול להיות שיהיו שינויים בתכונות ובסכימות.
- כלים בהתאמה אישית: כרגע אי אפשר לספק לסוכן Deep Research כלים מותאמים אישית של Function Calling או שרתי MCP (Model Context Protocol) מרוחקים.
- פלט מובנה ואישור תוכנית: סוכן המחקר המתקדם לא תומך כרגע בתכנון שאושר על ידי בני אדם או בפלט מובנה.
- זמן המחקר המקסימלי: לסוכן Deep Research יש זמן מחקר מקסימלי של 60 דקות. רוב המשימות אמורות להסתיים תוך 20 דקות.
- דרישה לחנות: כדי להפעיל נציג באמצעות
background=True, צריךstore=True. - חיפוש Google: חיפוש Google מופעל כברירת מחדל, ויש הגבלות ספציפיות על התוצאות המבוססות על מידע.
- קלט אודיו: אין תמיכה בקלט אודיו.
המאמרים הבאים
- מידע נוסף על Interactions API
- מידע על מודל Gemini 3 Pro שמפעיל את הסוכן הזה
- כך משתמשים בנתונים שלכם באמצעות הכלי 'חיפוש קבצים'.