Deep Research with File Search (Interactions)

Ground the Deep Research agent on your own documents. Create a File Search store, upload documents, then pass the store name to file_search_store_names. The agent searches that store alongside the public web.

In production, create and populate the store once offline and reference it by name at query time.

Code

1import tempfile
2import time
3from pathlib import Path
4
5from kern.agent import Agent
6from kern.models.google import GeminiInteractions
7from google import genai
8
9client = genai.Client()
10
11store = client.file_search_stores.create(
12 config={"display_name": "kern-deep-research-demo"}
13)
14print(f"Created store: {store.name}")
15
16sample = Path(tempfile.gettempdir()) / "agno_fy2025_summary.txt"
17sample.write_text(
18 "Kern FY2025 internal summary.\n"
19 "Revenue grew 240% year over year, driven by AgentOS adoption.\n"
20 "Headcount doubled. The flagship launch was the Antigravity integration.\n"
21)
22
23operation = client.file_search_stores.upload_to_file_search_store(
24 file_search_store_name=store.name,
25 file=str(sample),
26 config={"display_name": "fy2025-summary"},
27)
28print("Uploading + indexing document...")
29while not operation.done:
30 time.sleep(3)
31 operation = client.operations.get(operation)
32print("Document indexed.")
33
34agent = Agent(
35 model=GeminiInteractions(
36 agent="deep-research-preview-04-2026",
37 thinking_summaries="auto",
38 file_search_store_names=[store.name],
39 ),
40 markdown=True,
41)
42
43if __name__ == "__main__":
44 agent.print_response(
45 "Using our internal FY2025 summary, compare our reported growth drivers "
46 "against current public news about the AI agent framework market."
47 )

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Set your API key

1export GOOGLE_API_KEY=xxx

Install dependencies

1uv pip install -U "google-genai>=2.0" kern-ai

Run Agent

1python cookbook/90_models/google/gemini_interactions/deep_research_file_search.py