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 tempfile2import time3from pathlib import Path45from kern.agent import Agent6from kern.models.google import GeminiInteractions7from google import genai89client = genai.Client()1011store = client.file_search_stores.create(12 config={"display_name": "kern-deep-research-demo"}13)14print(f"Created store: {store.name}")1516sample = 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)2223operation = 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.")3334agent = 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)4243if __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.122source .venv/bin/activate1uv venv --python 3.122.venv\Scripts\activateSet your API key
1export GOOGLE_API_KEY=xxxInstall dependencies
1uv pip install -U "google-genai>=2.0" kern-aiRun Agent
1python cookbook/90_models/google/gemini_interactions/deep_research_file_search.py